Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

print-error or form-error in system ?

 [1/4] from: anton::lexicon::net at: 13-Nov-2002 19:19


Hi I am looking for a function just as Volker wrote about last year. Has anyone noticed if there is such a function lying around in the system somewhere? I think it must exist somewhere, I just haven't found it. Anton. Volker wrote last year on 21 December 2001: ------------------------- 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

 [2/4] from: tim:johnsons-web at: 13-Nov-2002 7:27


Hi Anton: Let me know if this works for you.... -tim- * Anton <[anton--lexicon--net]> [021112 23:27]:
> Hi I am looking for a function just as Volker wrote > about last year.
<<quoted lines omitted: 26>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com -- Attached file included as plaintext by Listar -- rebol[] cat: :rejoin print-error: func[ error [object!] /at location /local arg1 arg2 arg3 message out user-raised][ print "<pre>" either at[ print cat ["==>ERROR in " location ":"] ][ print "==>ERROR:" ] ;;; print mold error out: make string! 100 set [arg1 arg2 arg3][error/arg1 error/arg2 error/arg3] if string? arg1[ if (find arg1 "[RAISED]") = arg1[ arg1: chomp/left arg1 "[RAISED]" user-raised: true ] ] message: get in get in system/error error/type error/id if block? message [bind message 'arg1] append out " " append out reform reduce message if all[error/near not user-raised][append out cat[newline " near:^/ " mold error/near ] ] if all[error/where not user-raised][append out cat[newline " where:^/ " mold error/where] ] print out ] chomp: func[str[string!] sub-str[string!] /right /left /first /last /all /local found sub-len the-chomp][ sub-len: length? sub-str the-chomp: [remove/part found sub-len] if left[if (found: find str sub-str) = str[do the-chomp] return str] if right[ if found: find/tail/last str sub-str[ if empty? found[ found: find/last str sub-str do the-chomp ] ] return str ] if first[ if found: find str sub-str[do the-chomp] return str ] if last[ if found: find/last str sub-str[do the-chomp] return str ] if all[ while[found: find str sub-str][ do the-chomp ] return str ] raise["function 'chomp must have one refinement of /right /left /first /last /all"] ] ; raise an error, adds a tag to identify it as a error string only raise: func[message[block!]][ make error! join "[RAISED]" cat message ];end func ; example "try/catch" construct application: [; execution block Print "THIS IS THE EXECUTION BLOCK" ] ;######################################################################### except: [print-error disarm err ] if error? set/any 'err try application except

 [3/4] from: tim:johnsons-web at: 13-Nov-2002 8:19


Hmmm! The attachment didn't take, so I'll imbed the files here... must have coffee before doing complicated things. ;---------------------------------------------------------- rebol[] cat: :rejoin print-error: func[ error [object!] /at location /local arg1 arg2 arg3 message out user-raised][ print "<pre>" either at[ print cat ["==>ERROR in " location ":"] ][ print "==>ERROR:" ] ;;; print mold error out: make string! 100 set [arg1 arg2 arg3][error/arg1 error/arg2 error/arg3] if string? arg1[ if (find arg1 "[RAISED]") = arg1[ arg1: chomp/left arg1 "[RAISED]" user-raised: true ] ] message: get in get in system/error error/type error/id if block? message [bind message 'arg1] append out " " append out reform reduce message if all[error/near not user-raised][append out cat[newline " near:^/ " mold error/near ] ] if all[error/where not user-raised][append out cat[newline " where:^/ " mold error/where] ] print out ] chomp: func[str[string!] sub-str[string!] /right /left /first /last /all /local found sub-len the-chomp][ sub-len: length? sub-str the-chomp: [remove/part found sub-len] if left[if (found: find str sub-str) = str[do the-chomp] return str] if right[ if found: find/tail/last str sub-str[ if empty? found[ found: find/last str sub-str do the-chomp ] ] return str ] if first[ if found: find str sub-str[do the-chomp] return str ] if last[ if found: find/last str sub-str[do the-chomp] return str ] if all[ while[found: find str sub-str][ do the-chomp ] return str ] raise["function 'chomp must have one refinement of /right /left /first /last /all"] ] ; raise an error, adds a tag to identify it as a error string only raise: func[message[block!]][ make error! join "[RAISED]" cat message ];end func ;---------------------------------------------------------- ; example "try/catch" construct application: [; execution block Print "THIS IS THE EXECUTION BLOCK" ] ;######################################################################### except: [print-error disarm err ] if error? set/any 'err try application except ;---------------------------------------------------------- I hope this is of some help. Tim Johnson <[tim--johnsons-web--com]> [021113 07:42]:
> Hi Anton: > Let me know if this works for you....
<<quoted lines omitted: 94>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [4/4] from: anton:lexicon at: 14-Nov-2002 18:34


Thanks Tim, However, the function form-error I found was enough. I just really wanted to find the one in the system. Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted