in reply to Pattern for a shell-style call + error response
Since you appear to want to die whenever an error occurs, how about using an assertion?
#! perl -slw use strict; sub good{ 0 } sub bad{ 1 } sub assert { return unless $_[ 0 ]; die join( ' : ', caller, $_[ 1 ] ) . "\n"; } assert good(), 'Good() produced an error'; assert bad(), 'Bad() produced an error'; __END__ C:\test>junk5 main : C:\test\junk5.pl : 13 : Bad() produced an error
If the error string is always available from the library, you might move that into the sub to save some typing, though it would be easier if GetErrorCode() can be called as a class method rather than an instance method.
|
|---|