octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Opinions: exceptions in user oct files


From: Mike Miller
Subject: Opinions: exceptions in user oct files
Date: Mon, 1 May 2017 13:39:22 -0700
User-agent: NeoMutt/20170113 (1.7.2)

Hi all,

With Octave 4.2, the error handling system has been redone using C++
exceptions. All errors in Octave are now implemented with a small
handful of custom exception classes. The interpreter catches this small
known set of exceptions and reacts accordingly, returning control to the
user's code or to the interactive prompt.

Other exceptions are not caught and cause the entire Octave interpreter
to be terminated immediately.

I am interfacing some code that throws exceptions, and every DEFUN ends
up defining its own try-catch block to handle the exceptions the same
way, turning them into a call to Octave's error() function.

I am curious what others think about this. What should the policy be
towards user functions in the form of C++ oct files that may throw
exceptions?

 - Should Octave catch any unknown exception object and turn it into a
   general error message, preventing the interpreter from a hard exit?

 - Or should Octave require that user code not throw any exceptions
   other than the ones that Octave knows how to handle?

I'm not talking about some sophisticated way to map C++ exception types
to Octave error IDs, just a fallback mechanism to prevent Octave from
being killed where possible.

-- 
mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]