ExceptionHandling

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

ExceptionHandling

Stefan Krecher
Hi,
i'm implementing the cloud-package-thing (for persisting and serving Amber packages). It is an enhancement to Görans FileServer.st
Because i'd like to generalize the calls to the server, i'm calling code like that: (Smalltalk current at: (params at: 1)) perform: (params at: 2) withArguments: {data}.
With params holding the Classname and the method to get executed and data the JSON-Data for the method.
This mechanism works fine but there seems to be a problem with Exceptions. When i do an Error signal: 'Buh!', i see the error logged in the node-console but it is neither caught by self try:[] catch:[] nor by [..] on: Error do: []
I'm raising the error in a method called via the beforementioned reflective call.
Am i missing something?
regards,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: ExceptionHandling

Nicolas Petton
That's odd.

It works fine here.
Can you show me a minimal test case?

The exception handler works fine both on top of node and in the browser
(they are different exception handlers)

What I did:

amber >> Error signal: 'oops'
a Repl>>eval:
a Compiler>>loadExpression:
a DoIt>>doIt
a BlockClosure>>value
Error>>signal:
oops

amber >> [Error signal: 'foo'] on: Error do: [:ex | Transcript show: ex]
a Error

Cheers,
Nico

On Mon, 2011-10-24 at 12:57 -0700, Stefan Krecher wrote:

> Hi,
> i'm implementing the cloud-package-thing (for persisting and serving
> Amber packages). It is an enhancement to Görans FileServer.st
> Because i'd like to generalize the calls to the server, i'm calling
> code like that: (Smalltalk current at: (params at: 1)) perform:
> (params at: 2) withArguments: {data}.
> With params holding the Classname and the method to get executed and
> data the JSON-Data for the method.
> This mechanism works fine but there seems to be a problem with
> Exceptions. When i do an Error signal: 'Buh!', i see the error logged
> in the node-console but it is neither caught by self try:[] catch:[]
> nor by [..] on: Error do: []
> I'm raising the error in a method called via the beforementioned
> reflective call.
> Am i missing something?
> regards,
> Stefan


Reply | Threaded
Open this post in threaded view
|

Re: ExceptionHandling

Stefan Krecher
Hi,
sorry, i guess that was my fault. I forgot the non-blocking message-handling in node ...
That was what i did: 
- received HTTP-Post-Request in node
- searching data in MongoDB
- throwing an Exception if Data was found
The problem was that right after calling the search-api, the execution-flow returns. The exception will be thrown into nowhere!
So i need to work with callbacks everywhere.
regards,
Stefan