[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH 1/1] Don't obscure errors with custom errors only


On 19 March 2012 15:28, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Thomas,
> Thomas Adam wrote:
>> When coming out of eval blocks and reporting on errors, make sure $@ is
>> included as part of the textual output so that the real underlying error is
>> reported.
>> ---
>>  I was recently bitten by this:
>>  dpkg-source: error: source package format `3.0 (native)' is not supported
>>  (Perl module Dpkg::Source::Package::V3::native is required)
>>  Of course, that file is being required just fine, the problem turned out
>>  to be missing File::Temp, but without including $@, I would never have
>>  know this, due to a custom error message completely hiding this detail.
> Small nit: in this example, I think the text after the three dashes
> makes a much better commit message than the text before them.

I can re-roll if you prefer?

> [...]
>> --- a/scripts/Dpkg/Source/Package.pm
>> +++ b/scripts/Dpkg/Source/Package.pm
>> @@ -233,7 +233,8 @@ sub upgrade_object_type {
>>              $self->{'fields'}{'Format'} .= " ($variant)" if defined $variant;
>>          }
>>          if ($@) {
>> -         error(_g("source package format `%s' is not supported (Perl module %s is required)"), $format, $module);
>> +         error(_g("source package format `%s' is not supported (Perl module %s is required): %s"),
>> +                     $format, $module, $@);
> If the Dpkg::Source::Package::V3::foo module is missing, will $@
> mention so?  I am asking because I wonder if
>        _g("source package format '%s' is not supported: %s')
> might not be a shorter way to convey the same information.

It should do, but it depends entirely on the intent of the original
error message, which is why I left that intact and merely appended the
extra content from $@.


Thomas Adam
Senior Developer


Smoothwall Ltd
1 John Charles Way, Leeds, LS12 6QA United Kingdom
Telephone:  USA: 1 800 959 3760  Europe: +44 (0) 8701 999500

Smoothwall Limited is registered in England, Company Number: 4298247.  This
email and any attachments transmitted with it are confidential to the
intended recipient(s) and may not be communicated to any other person or
published by any means without the permission of Smoothwall Limited.  Any
opinions stated in this message are solely those of the author.

Reply to: