os_generate_error and postmortems

Stefan Bellon sbellon at sbellon.de
Tue Aug 24 20:22:32 BST 2004


Tom Hughes wrote:
> In message <4ce39ceac5sbellon at sbellon.de>
>           Stefan Bellon <sbellon at sbellon.de> wrote:

> > I'm stumbling over the fact that os_generate_error() always
> > produces a postmortem with stack trace which I don't want. How
> > should I do it if I only want an error message (printed on screen
> > when from within the CLI or in an error box when from within the
> > WIMP) and a return code?

> Not really an OSLib question...

Ah, I realized just now that the same happens with this code:

#include <kernel.h>
#include <swis.h>

int main(void)
{
    _kernel_oserror err = { 0, "foobar" };
    
    _swi(OS_GenerateError, _IN(0), &err);
}

Therefore, you're right, no OSLib question.

> Try trapping SIGOSERROR which is what I would expect it to raise. That
> will probably stop all the default actions though, so you will need to
> report the error yourself.

Ok, so let me rephrase my question. What's the proper way of doing what
the following short BASIC program does:

DIM err% 256

!err% = 0
$(err%+4) = "foobar"+CHR$0

SYS "OS_GenerateError", err%

If you save this to a file and then start the BASIC file from within a
TaskWindow, then the error message is printed in the TaskWindow. If you
double-click on the file in the Filer, then the error appears in an
error box.

I'd like to achieve the same effect from within a C program that uses
OSLib. Initially I thought os_generate_error is the way to go. Is there
another way?

TIA.

-- 
Stefan Bellon



More information about the oslib-user mailing list