[mercury-users] question about error/1

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Jan 24 13:26:16 AEDT 2008


On Thu, 24 Jan 2008, Mark Brown wrote:

> Hi Nick,
>
> On 24-Jan-2008, Nicholas Nethercote <njn at csse.unimelb.edu.au> wrote:
>> On Thu, 24 Jan 2008, Ralph Becket wrote:
>>
>>>> When I call error/1, the program terminates with a message like this:
>>>>
>>>>   Uncaught Mercury exception:
>>>>   Software Error: <message>
>>>>
>>>> Is it possible to omit the "Uncaught Mercury exception: Software Error:"
>>>> bit?
>>>
>>> That's rather the point of error/1.  You just use throw/1 for other
>>> exceptions.
>>
>> I just want to abort easily with a message of my choosing.  Instead I get a
>> message of my choosing plus some other stuff, which will likely confuse
>> users.  To avoid that confusion, I have to use 'try' + I/O, which is a
>> hassle.
>>
>> In short, it would be nice to be able to abort with a message of my
>> choosing.
>
> The implementation of error/1 is
>
>    error(Message) :-
>        throw(software_error(Message)).
>
> so I think throw/1 is what you want.

You will still get the message about the uncaught exception if you
don't catch it - that behaviour is hardcoded into the runtime and
there isn't a mechanism for changing it.

Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list