[Pharo-project] Exception logging
Hi guys when I do the following |file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close]. I get a pop up DNU poipuiu while I would like to get the stack on the stream. May be my mistake is obvious but I do not see it. Stef
On Mon, Jan 16, 2012 at 7:08 PM, Stéphane Ducasse <stephane.ducasse@inria.fr
wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
Stef. If I understand correctly, ex outer will do ""Evaluate the enclosing exception action and return to here instead of signal if it resumes (see #resumeUnchecked:)."" So what you have to do is to use #signalerContext. Example: |file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 adas') asString] on: Error do: [:ex | ex signalerContext errorReportOn: file ]. ] ensure: [file close]. I think that does what you need.
May be my mistake is obvious but I do not see it.
Stef
-- Mariano http://marianopeck.wordpress.com
On Mon, Jan 16, 2012 at 10:11 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
On Mon, Jan 16, 2012 at 7:08 PM, Stéphane Ducasse < stephane.ducasse@inria.fr> wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
Stef. If I understand correctly, ex outer will do "" Evaluate the enclosing exception action and return to here instead of signal if it resumes (see #resumeUnchecked:).""
Notice that #outer does a pass (kind of throw again) at the end: outer "Evaluate the enclosing exception action and return to here instead of signal if it resumes (see #resumeUnchecked:)." | prevOuterContext | self isResumable ifTrue: [ prevOuterContext := outerContext. outerContext := thisContext contextTag ]. self pass.
So what you have to do is to use #signalerContext. Example:
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 adas') asString] on: Error do: [:ex | ex signalerContext errorReportOn: file ]. ] ensure: [file close].
I think that does what you need.
May be my mistake is obvious but I do not see it.
Stef
-- Mariano http://marianopeck.wordpress.com
-- Mariano http://marianopeck.wordpress.com
On Mon, Jan 16, 2012 at 07:08:49PM +0100, St?phane Ducasse wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
Try "ex signalerContext errorReportOn: file" instead of "ex outer errorReportOn: file". Dave
check Exception >> #outer "Evaluate the enclosing exception action and return to here instead of signal if it resumes (see #resumeUnchecked:)." what you probably want is ... [ ex signalerContext errorReportOn: file ] cami On 2012-01-16, at 19:08, Stéphane Ducasse wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
May be my mistake is obvious but I do not see it.
Stef
Thanks guys now what is really strange to me is that whe the code does not contain error to make it compile I have to wrap it with on:do: Any idea?
and if I wrap the execution with a on: error do: I get Start33 in the file
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: ((OCClosureCompiler new compile: 'foo ^ 33.' in: Object classified: nil notifying: nil ifFail: []) generate valueWithReceiver: Object new arguments: #()) asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close]. [true] whileTrue: [Beeper primitiveBeep. ]] newProcess
if I remove the on:do: I do not get anything no beep.
Silly question, but what happens to your newProcess if you don't resume it? [Beeper primitiveBeep] newProcess. won't beep... But: [Beeper primitiveBeep] newProcess resume. will... If you did resume then - What is OCClosureCompiler? - Does it generate an exception? - Did you try with a regular Compiler? With a regular Compiler I clearly here the buzzer. Nicolas 2012/1/17 Stéphane Ducasse <stephane.ducasse@inria.fr>:
Thanks guys now what is really strange to me is that whe the code does not contain error to make it compile I have to wrap it with on:do: Any idea?
and if I wrap the execution with a on: error do: I get    Start33 in the file
OCClosureCompiler
if I remove the on:do: I do not get anything no beep.
2012/1/17 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
Silly question, but  what happens to your newProcess if you don't resume it?
 [Beeper primitiveBeep] newProcess.
won't beep... But:
 [Beeper primitiveBeep] newProcess resume.
will...
If you did resume then - What is OCClosureCompiler? - Does it generate an exception? - Did you try with a regular Compiler?
With a regular Compiler I clearly here the buzzer.
hem... hear
Nicolas
2012/1/17 Stéphane Ducasse <stephane.ducasse@inria.fr>:
Thanks guys now what is really strange to me is that whe the code does not contain error to make it compile I have to wrap it with on:do: Any idea?
and if I wrap the execution with a on: error do: I get    Start33 in the file
OCClosureCompiler
if I remove the on:do: I do not get anything no beep.
On Jan 17, 2012, at 10:07 PM, Nicolas Cellier wrote:
Silly question, but what happens to your newProcess if you don't resume it?
[Beeper primitiveBeep] newProcess.
won't beep... But:
[Beeper primitiveBeep] newProcess resume.
willâ¦
The problem is that this new process is the only one (yes only one) of a strange image I generated with hazelnuts (I need to get the compiler working so that we even evaluate an expression in this image :).
If you did resume then - What is OCClosureCompiler? I tried with OPAL because it did not work with the Compiler but since I cannot debug it this is why I open a file and put information inside :)
- Does it generate an exception? no
- Did you try with a regular Compiler? yes but it does not work.
in fact I do not understand why yesterday [Compiler evaluate: '1 foooo' ] on: Error do: [:ex | ex inspect] did not work and today it does :) so I guess that I should sleep more. Thanks nicolas I should sleep more and breath deeper :). Stef
With a regular Compiler I clearly here the buzzer.
Nicolas
2012/1/17 Stéphane Ducasse <stephane.ducasse@inria.fr>:
Thanks guys now what is really strange to me is that whe the code does not contain error to make it compile I have to wrap it with on:do: Any idea?
and if I wrap the execution with a on: error do: I get Start33 in the file
OCClosureCompiler
if I remove the on:do: I do not get anything no beep.
Looks like Compiler might use it's own error handler? Max On Mon, Jan 16, 2012 at 7:08 PM, Stéphane Ducasse <stephane.ducasse@inria.fr
wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
May be my mistake is obvious but I do not see it.
Stef
It's more tricky than that... Try this one that works: |file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | file nextPutAll: 'failed']. ] ensure: [file close]. Nicolas 2012/1/16 Max Leske <maxleske@gmail.com>:
Looks like Compiler might use it's own error handler?
Max
On Mon, Jan 16, 2012 at 7:08 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
May be my mistake is obvious but I do not see it.
Stef
Oh, but it's just that (ex outer) will pass the exception to an upper level outer "Evaluate the enclosing exception action and return to here instead of signal if it resumes (see #resumeUnchecked:)." | prevOuterContext | self isResumable ifTrue: [ prevOuterContext := outerContext. outerContext := thisContext contextTag ]. self pass. Nicolas 2012/1/16 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
It's more tricky than that... Try this one that works:
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | file nextPutAll: 'failed']. ] ensure: [file close].
Nicolas
2012/1/16 Max Leske <maxleske@gmail.com>:
Looks like Compiler might use it's own error handler?
Max
On Mon, Jan 16, 2012 at 7:08 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
May be my mistake is obvious but I do not see it.
Stef
Hello Stefan. The error seem there is in the do: block... I try this and works ok: |file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex |* 'not ok' inspect* ]. ] ensure: [file close]. 2012/1/16 Stéphane Ducasse <stephane.ducasse@inria.fr>
Hi guys
when I do the following
|file| [ file := StandardFileStream fileNamed: 'loglog.txt'. file nextPutAll: 'Start'. [ file nextPutAll: (Compiler evaluate: '55 + 88 poipuiu') asString] on: Error do: [:ex | ex outer errorReportOn: file]. ] ensure: [file close].
I get a pop up DNU poipuiu while I would like to get the stack on the stream.
May be my mistake is obvious but I do not see it.
Stef
participants (7)
-
Camillo Bruni -
David T. Lewis -
Gastón Dall' Oglio -
Mariano Martinez Peck -
Max Leske -
Nicolas Cellier -
Stéphane Ducasse