Errors and Exceptions in Newspeak

34 views
Skip to first unread message

Rouan van Dalen

unread,
Apr 19, 2013, 9:37:56 AM4/19/13
to newspeak...@googlegroups.com
Hi everyone,

Why do we have Error and Exception in Newspeak?

And when do I use which?

Currently I am using:

    Error signal: 'some error message'

for signalling general exceptions

If I would like my to create my own specialised exception class, do I inherit from Error or Exception?

Regards
--Rouan

Frank Shearar

unread,
Apr 19, 2013, 9:48:52 AM4/19/13
to newspeak...@googlegroups.com
Exception is the base class for all non-local signalling. Its two main
subclasses are Notification and Error.

If something bad goes wrong, you want to signal Error.

Some kinds of Exceptions are resumable: look at implementors of #isResumable.

frank

> Regards
> --Rouan

Eliot Miranda

unread,
Apr 19, 2013, 1:12:09 PM4/19/13
to newspeak...@googlegroups.com
On Fri, Apr 19, 2013 at 6:37 AM, Rouan van Dalen <r...@sftreal.co.za> wrote:
Hi everyone,

Why do we have Error and Exception in Newspeak?

And when do I use which?

Currently I am using:

    Error signal: 'some error message'

for signalling general exceptions

You might want to implement error: at the top=-level of your module:

error: str = (Error signal: str)

It's a nice short-hand; I miss it not being in Newspeak's Object.  Interesting tension between having useful facilities in Object with inevitable dependencies, vs defining everything oneself, defining the dependencies explicitly but reinventing the wheel and/or writing much more verbose code.

If I would like my to create my own specialised exception class, do I inherit from Error or Exception?

From Error, or one of its subclasses.
 

Regards
--Rouan



--
best,
Eliot

Rouan van Dalen

unread,
Apr 20, 2013, 3:30:26 AM4/20/13
to newspeak...@googlegroups.com
Thanks Frank & Eliot,

I have a better idea of where to go from here with exceptions.

I do not create the error: shorthand.

What I implement at the top module is just a binding to the Error class:

    private Error = platform exceptions Error.

and then write code like this:

    index > list size
        ifTrue: [ Error signal: 'index too high' ].

Regards
--Rouan
Reply all
Reply to author
Forward
0 new messages