Hi, I have some questions on error reporting. I wrote this verb, I thought could be handy alongside the assert verb in the standard library:
assertno =: 0 0$([ 13!:8~ ],~(LF,'| '),~ (9!:8'') {::~ <:@[)&>/@[^:(0 e. ]) it takes as x: error_number;'message', and as y the same as for assert (i. e. it throws the error if 0 is an element in y). The error thrown will be error number as specified, have a default header (as per 9!:8'') and an additional custom text. For instance: (3;'my message') assertno 0 |domain error | my message: assertno | (3;'my message') assertno 0 It allows passing a bit more context to a user, in my opinion useful, to give more info instead of a mere assertion error, especially in library code/OOP contexts. That said, is such use of the error numbers/messages recommended/allowed/frowned upon/silly? Another question I have with regards to errors happening with a changed locale. I have: ret=: coname'' cocurrent 'other' do_stuff'' NB. could throw error cocurrent ret If do_stuff errors, the code ends up in the 'other' locale, which is especially bad if it happens in library code taking for instance a user verb it doesn't have control over. Now I'd like to wrap the "do stuff" in a try-catch, such that in the catch, the locale is reset to ret if do_stuff throws an error, to afterwards re-throw the exact same error. I tried to find a solution, but using (dberm dbsig dberr)'' sort of jumbles the message. Is there a better way of simply forwarding the error without touching it? Thanks, Jan-Pieter PS: I'm preparing an update to my types_dict addon, that's why I'm coming up with so many questions. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm