RE: [REBOL] Coerting Errors to a string?
(original by Bo somewhere, called print-error. forgot if i changed something.)
form-error: func [
error [object!]
/local arg1 arg2 arg3 message out
] [
out: make string! 100
set [arg1 arg2 arg3] [error/arg1 error/arg2 error/arg3]
message: get in get in system/error error/type error/id
if block? message [bind message 'arg1]
append out reform reduce message
append out reform ["^/Near:" mold error/near]
append out reform ["^/Where:" mold get in error 'where]
]
use with [print form-error disarm error]
-Volker
[EMAIL PROTECTED] wrote:
>
> Hi Guys,
>
> Given that my program recieves an error I disarm it, and I have an error object, for
> example
>
> err: disarm try [a: 1 / 0]
>
> probe err
>
> make object! [
> code: 400
> type: 'math
> id: 'zero-divide
> arg1: none
> arg2: none
> arg3: none
> near: [a: 1 / 0]
> where: none
> ]
>
> How do I convert it to a nicely formatted readable string ?
>
> >> err
> ** Math Error: Attempt to divide by zero
> ** Near: a: 1 / 0
>
>
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.