Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try { /* init code here */ }
- catch (Exception ex)
- {
- try
- {
- _DeinitializeEngine();
- }
- catch (Exception ex2)
- {
- throw new OCRException("Engine failed to initialize; ALSO failed to deinitialize engine!", ex2);
- }
- finally
- {
- throw new OCRException("Engine failed to initialize; failed to initialize license!", ex);
- }
- }
- static void Main(string[] args)
- {
- try
- {
- principalMethod();
- }
- catch (Exception e)
- {
- Console.WriteLine("Test : " + e.Message);
- }
- Console.Read();
- }
- public static void principalMethod()
- {
- try
- {
- throw new Exception("Primary");
- }
- catch (Exception ex1)
- {
- try
- {
- methodThatCanCrash();
- }
- catch
- {
- throw new Exception("Cannot deinitialize", ex1);
- }
- }
- }
- private static void methodThatCanCrash()
- {
- throw new NotImplementedException();
- }
- try { /* init code here */ }
- catch (Exception ex)
- {
- // Passing original exception as inner exception
- Exception ocrex = new OCRException("Engine failed to initialize", ex);
- try
- {
- _DeinitializeEngine();
- }
- catch (Exception ex2)
- {
- // Passing initialization failure as inner exception
- ocrex = new OCRException("Failed to deinitialize engine!", ocrex);
- }
- throw ocrex;
- }
Add Comment
Please, Sign In to add comment