catching exceptions...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

catching exceptions...

Joachim Jaeckel
Hello,

my question today is about catching exceptions.

I have an exception, which is subclassed from Notification, so if I'm
not catching it, it's absolutely silent.

But if I want to catch it, how could I do printout the whole information
(like the printStackTrace in Java...)?

...

And to make sure, I'm on the right way, my Exception is defined as:

Notification subclass: NotBase64Encoded [

     description [
         ^'String is not Base64 encoded'
     ]

]

and I throw it with:

^NotBase64Encoded new signal: ('String: ''%1'' is not base64 encoded'
bindWith: aString)

Thanks in advance,
Joachim.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: catching exceptions...

Paolo Bonzini-3
Interestingly enough, the same question was answered in an Iliad thread...

A method that does what you want is present in Seaside:

Signal extend [
     resumeContext [
         ^resumeBlock outerContext home
     ]
]

then you can do

[Notification signal]
    on: Notification
    do: [:ex | ex resumeContext backtrace]

Actually a nicer backtrace can be obtained with

Signal extend [
     resumeContext [
         | context |
         context := resumeBlock outerContext home.
         [context isInternalExceptionHandlingContext]
             whileTrue: [context := context parentContext].
         ^context
     ]
]

I'm adding this to the standard library, though under the name
#signalingContext.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: catching exceptions...

Joachim Jaeckel
> Interestingly enough, the same question was answered in an Iliad thread...

Ups, sorry Paolo!

But I understand the iliad thread as "how to print additional and nicer
information.

I didn't get, that that thread was answered there...

Sorry again.

Joachim.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: catching exceptions...

Stefan Schmiedl
On Sun, 28 Jun 2009 23:35:26 +0200
Joachim Jaeckel <[hidden email]> wrote:

> > Interestingly enough, the same question was answered in an Iliad
> > thread...
>
> Ups, sorry Paolo!
>
> But I understand the iliad thread as "how to print additional and
> nicer information.
>
> I didn't get, that that thread was answered there...

The problem was that the backtrace given by a naive

        error context backtrace

shows the callstack on the Swazoo side of the fence, i.e.
is totally irrelevant to your localizing the bug.

I needed the solution using "outerContext home", which will be folded
into #signalingContext (nice choice of words) to display the backtrace
leading into "my" code.

s.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk