Niels Thykier <ni...@thykier.net> writes: > On 2013-04-04 01:52, Russ Allbery wrote:
>> For some larger, more complicated code, I've thought about switching to >> OO exception objects, since that seems to be a best practice and lets >> you do some other interesting things, like carry a lot more context >> information. It may be worth seeing whether a Lintian::Exception class >> combined with a general switch to throw/catch programming would >> simplify any major sections of code. > Creating a Lintian::Exception class shouldn't be much of a problem. Do > you have any recommendation on what to use as a base class (if any). I > know only of autodie::exception + Exception::Class. My limited use of > exceptions in Perl leaves me at a disadvantage here. I haven't investigated it, and the code that I have that currently does this doesn't use any base class. Perl Best Practices recommends Exception::Class, so I'd probably start looking there, but the book is fairly old and there may be something better out there now. > Ah, that makes sense. I just learned that autodie also have an issue with: > open(STDERR, '>&', STDOUT); > (requring the latter bareword to be \*STDOUT to avoid a syntax error). > But it still beats having to check every single open/close call, so... :) Yeah. :) I actually prefer that syntax anyway; I've gotten kind of allergic to barewords. > Turns out not even "consistent call style" can help you here: > """ > $ perl -Mautodie=print -e '' > Cannot make the non-overridable builtin print fatal at -e line 0 > BEGIN failed--compilation aborted. > """ > Looks like wrapping is the only way to go with print. Right, autodie declines to even attempt to wrap print because of the prototype issues. (I kind of wish there was some way to tell it to be less conservative, but there doesn't appear to be.) -- Russ Allbery (r...@debian.org) <http://www.eyrie.org/~eagle/> -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/87wqsgwddc....@windlord.stanford.edu