Re: Correct way to throw exceptions/errors from C to ST

Paolo Bonzini <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <[email protected]>

On 04/04/2015 02:50, Roland Plüss wrote:
> Another something that I could not really figure out using the 
> documentations. Let's say you have a CCallOut from ST to C. Inside
> this C function something goes wrong, for example an invalid
> argument passed. How do you properly raise an exception back to
> Smalltalk? I tried doing something like this:
> 
> gst_eval_code( "SystemExceptions.InvalidArgument new signal" );
> 
> But this causes the VM to call abort since an exception happened
> outside the bytecode. I assume you need to be more clever in this
> case. So what is the correct way to throw these kinds of exceptions
> from inside a C function?

You return a C-style error and have a Smalltalk wrapper convert it to
a Smalltalk exception.  Or you do argument checking in Smalltalk and
the rest in C.

Paolo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.