In answering this question, I suggested that the OP open a stream at the beginning of his notebook and close it at the end. However, if an Abort
is generated, the stream will be left open, and will cause havoc if they attempt to open it again without checking first. If the stream was only required for a single function, the solution would be straightforward, but it's required for the entire notebook. Obviously, a check can be added to see if the stream is already open, but is there a way to tie into the global Abort
handler so that this type of problem can be handled globally?
Edit: to be specific, I'm looking for a way to run arbitrary code when an Abort
occurs whether, or not, the code is currently running inside of CheckAbort
. Essentially, I'd like to set a global Abort
handler, if possible. If this exists at the notebook level, then even better.