Browse Source

Fix SD-1569 - Errors deleting a folder in projects pad cause unhandled exception

pull/14/head
Matt Ward 15 years ago
parent
commit
9c333a8e6c
  1. 14
      src/Main/Base/Project/Src/Services/File/FileService.cs
  2. 27
      src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

14
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -412,8 +412,7 @@ namespace ICSharpCode.SharpDevelop @@ -412,8 +412,7 @@ namespace ICSharpCode.SharpDevelop
Directory.Delete(fileName, true);
}
} catch (Exception e) {
MessageService.ShowException(e, "Can't remove directory " + fileName);
// return;
MessageService.ShowHandledException(e, "Can't remove directory " + fileName);
}
} else {
try {
@ -424,8 +423,7 @@ namespace ICSharpCode.SharpDevelop @@ -424,8 +423,7 @@ namespace ICSharpCode.SharpDevelop
File.Delete(fileName);
}
} catch (Exception e) {
MessageService.ShowException(e, "Can't remove file " + fileName);
// return;
MessageService.ShowHandledException(e, "Can't remove file " + fileName);
}
}
}
@ -464,9 +462,9 @@ namespace ICSharpCode.SharpDevelop @@ -464,9 +462,9 @@ namespace ICSharpCode.SharpDevelop
}
} catch (Exception e) {
if (isDirectory) {
MessageService.ShowException(e, "Can't rename directory " + oldName);
MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
} else {
MessageService.ShowException(e, "Can't rename file " + oldName);
MessageService.ShowHandledException(e, "Can't rename file " + oldName);
}
return false;
}
@ -508,9 +506,9 @@ namespace ICSharpCode.SharpDevelop @@ -508,9 +506,9 @@ namespace ICSharpCode.SharpDevelop
}
} catch (Exception e) {
if (isDirectory) {
MessageService.ShowException(e, "Can't copy directory " + oldName);
MessageService.ShowHandledException(e, "Can't copy directory " + oldName);
} else {
MessageService.ShowException(e, "Can't copy file " + oldName);
MessageService.ShowHandledException(e, "Can't copy file " + oldName);
}
return false;
}

27
src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

@ -52,6 +52,33 @@ namespace ICSharpCode.Core @@ -52,6 +52,33 @@ namespace ICSharpCode.Core
ServiceManager.Instance.MessageService.ShowException(ex, message);
}
/// <summary>
/// Shows an exception.
/// </summary>
public static void ShowHandledException(Exception ex)
{
ShowHandledException(ex, null);
}
/// <summary>
/// Shows an exception.
/// </summary>
public static void ShowHandledException(Exception ex, string message)
{
LoggingService.Error(message, ex);
LoggingService.Warn("Stack trace of last exception log:\n" + Environment.StackTrace);
message = GetMessage(message, ex);
ServiceManager.Instance.MessageService.ShowError(message);
}
static string GetMessage(string message, Exception ex)
{
if (message == null) {
return ex.Message;
}
return message + "\r\n\r\n" + ex.Message;
}
/// <summary>
/// Shows a warning message.
/// </summary>

Loading…
Cancel
Save