Smb write, delete, fixes, error handling
This commit is contained in:
@@ -11,7 +11,27 @@ namespace FileTime.Avalonia.Converters
|
||||
if (value is not Exception e) return value;
|
||||
|
||||
if (e is UnauthorizedAccessException) return e.Message;
|
||||
else if (e.InnerException != null)
|
||||
{
|
||||
return TraverseInnerException(e);
|
||||
}
|
||||
|
||||
return FormatException(e);
|
||||
}
|
||||
|
||||
private static string TraverseInnerException(Exception e)
|
||||
{
|
||||
string s = "";
|
||||
if (e.InnerException != null) s += TraverseInnerException(e.InnerException) + Environment.NewLine;
|
||||
else return FormatException(e);
|
||||
|
||||
s += "In: " + FormatException(e);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private static string FormatException(Exception e)
|
||||
{
|
||||
return $"{e.Message} ({e.GetType().FullName})";
|
||||
}
|
||||
|
||||
|
||||
@@ -268,9 +268,18 @@ namespace FileTime.Avalonia.Services
|
||||
{
|
||||
var handler = async (List<InputElementWrapper> inputs) =>
|
||||
{
|
||||
var container = _appState.SelectedTab.CurrentLocation.Container;
|
||||
var createContainerCommand = new CreateContainerCommand(new AbsolutePath(container), inputs[0].Value);
|
||||
await AddCommand(createContainerCommand);
|
||||
string? containerName = null;
|
||||
try
|
||||
{
|
||||
containerName = inputs[0].Value;
|
||||
var container = _appState.SelectedTab.CurrentLocation.Container;
|
||||
var createContainerCommand = new CreateContainerCommand(new AbsolutePath(container), containerName);
|
||||
await AddCommand(createContainerCommand);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Error while creating container {Container}", containerName);
|
||||
}
|
||||
};
|
||||
|
||||
_dialogService.ReadInputs(new List<InputElement>() { new InputElement("Container name", InputType.Text) }, handler);
|
||||
@@ -282,9 +291,18 @@ namespace FileTime.Avalonia.Services
|
||||
{
|
||||
var handler = async (List<InputElementWrapper> inputs) =>
|
||||
{
|
||||
var container = _appState.SelectedTab.CurrentLocation.Container;
|
||||
var createElementCommand = new CreateElementCommand(new AbsolutePath(container), inputs[0].Value);
|
||||
await AddCommand(createElementCommand);
|
||||
string? elementName = null;
|
||||
try
|
||||
{
|
||||
elementName = inputs[0].Value;
|
||||
var container = _appState.SelectedTab.CurrentLocation.Container;
|
||||
var createElementCommand = new CreateElementCommand(new AbsolutePath(container), elementName);
|
||||
await AddCommand(createElementCommand);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Error while creating element {Element}", elementName);
|
||||
}
|
||||
};
|
||||
|
||||
_dialogService.ReadInputs(new List<InputElement>() { new InputElement("Element name", InputType.Text) }, handler);
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace FileTime.Avalonia.Services
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Unknown error while running commnad. {Command}", command);
|
||||
_logger.LogError(e, "Unknown error while running command. {Command} {Error}", command, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,19 @@ namespace FileTime.Avalonia.Services
|
||||
if (container == null) continue;
|
||||
|
||||
var newTab = new Tab();
|
||||
await newTab.Init(container);
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (container == null) throw new Exception($"Could not find an initializable path along {tab.Path}");
|
||||
await newTab.Init(container);
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
container = container!.GetParent();
|
||||
}
|
||||
}
|
||||
|
||||
var newTabContainer = new TabContainer(newTab, _localContentProvider, _itemNameConverterService);
|
||||
await newTabContainer.Init(tab.Number);
|
||||
|
||||
@@ -323,7 +323,7 @@
|
||||
<ItemsRepeater Grid.Row="1" Items="{Binding AppState.SelectedTab.ChildContainer.Exceptions}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding, Converter={StaticResource ExceptionToStringConverter}}"/>
|
||||
<TextBlock Margin="5,0,5,10" Text="{Binding, Converter={StaticResource ExceptionToStringConverter}}"/>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
|
||||
Reference in New Issue
Block a user