I'm writing a C# application (in Linux with mono but it shouldn't matter) and I am programming with duplicati dlls. I want that the program never crashes so I tried to catch every exception. The Problem now is that an exception is thrown and I can't catch it. Maybe from a thread?!?
Sidenote: Just for testing purposes I intentionally tried to backup to a Location where I don't have permission. If I give permission, then I get no error.
The code Looks like the following:
try {
Interface i = new Interface(backend, options);
result = i.Backup(folders.ToArray());
} catch (Exception e) {
//Write to log.
//Here is no throw; !!
}
I get the following stack trace:
Error : System.Exception: Failed to retrieve file listing: Access to the path "/home/pi/test" is denied. ---> System.UnauthorizedAccessException: Access to the path "/home/pi/test" is denied.
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetFiles (System.String path) [0x00000] in <filename unknown>:0
at Duplicati.Library.Backend.File.List () [0x00000] in <filename unknown>:0
at Duplicati.Library.Main.BackendWrapper.ListInternal () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Duplicati.Library.Main.BackendWrapper.ListInternal () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Why am I unable to catch all exceptions? Am I doing something wrong?