Background
I am developing software running in a larger executive program, to which I can communicate using only its API. After extensive testing, I've determined there is an architecture problem in the executive concerning how it handles exceptions.
The executive program has its own exception handling in the form of a pop-up dialog providing the user with information about the exception. Based on the program's behavior, I suspect it resembles this:
// Executive Program
try {
// A simple state machine controlling execution mode within the Executive Program
// Not actually certain a switch is used, but this is representative of behavior
switch(executiveStateMachine){
case setUp:
// [....]
break;
case starting:
// [....]
break;
case run:
while(true){
// [...]
// My software running inside executive program
// [...]
// Eventual break after successful completion
break;
}
break;
case finish:
// [....]
break;
}
}
catch(Exception except){
// On any, show a proprietary exception dialog
if(ExceptionDialog.ShowDialog(Exception) == DialogResult.OK) break;
}
When handling exceptions, it appears the Executive Program occasionally creates fatal errors within its state machine transitions causing the entire program to crash.
While I've filed a bug request with the Executive's Developer, I don't think it will be fixed any time soon and would really like to handle both my own software's exceptions and the Executive Program's exceptions myself.
Question; (TLDR)
Is it possible in C# to catch an exception using some method before a larger, encapsulating (and unseen) try-catch block can?