Search code examples
smalltalksqueak

catching the assertion failure message before handling it


I know how to raise an exception and how to handle it , but suppose I have this method:

method1:arg
AssertionFailure signal:'rescue error comment'.

I want to catch this exception and create new Assertion failure exception with another format.However I need to get that message ("rescue error comment") and use it in my new exception.. and this is where I don't know what to do...

so how do I get that message before the handling the exeption by using

   on: AssertionFailure  do:

Solution

  • Either use

    on: AssertionFailure do: [ :e | NewAssertionFailure signal: e messageText ]
    

    or define method as

    method1:arg
        NewAssertionFailure signal: 'rescue error comment'