octave-maintainers
[Top][All Lists]
Advanced

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

Re: try/catch not swallowing errors


From: Daniel Kraft
Subject: Re: try/catch not swallowing errors
Date: Sat, 13 Apr 2019 17:24:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Hi Rik!

On 13.04.19 17:14, Rik wrote:
> On 04/13/2019 05:38 AM, address@hidden wrote:
>> I just noticed something weird:  With the code below, the error message
>> generated by "fload" for reading from an EOF stream ("could not read
>> binary header") is printed even though the error is caught (although
>> execution continues without an error being flagged, which is correct).
>> The Octave documentation for try-catch clearly states that also error
>> messages are not printed.
>>
>> pkg load parallel;
>> try
>>   [r, w] = pipe ();
>>   fclose (w);
>>   fload (r);
>> catch
>> end_try_catch
>
> This looks like something worth investigating.
> 
> I used this test code in a file tst_try.m
> 
> function tst_try
>   try
>     subfcn1 ();
>   catch
>   end_try_catch
> endfunction
> 
> function subfcn1
>   error ("Throw an error in subfcn1");
> endfunction
> 
> When run, the error in the subfunction is not displayed.  Hence, I don'
> think the error in fload should be displayed either.

Yes, that's what I would expect.  I also tried doing what you did with a
custom .oct file, but the error was still not displayed in that case for me.

> You might try debug_on_error (1) and inspect where the error is being
> generated.  Maybe the code uses printf rather than error or something
> like that.

As far as I can tell, this is where the error is generated:

https://sourceforge.net/p/octave/parallel/ci/default/tree/src/fload.cc#l53

That looks correct to me.  When I do exactly the same (use error() in
C++) in an .oct file of mine, it works, though.  That's why I guess it
could be related to packages somehow.

Yours,
Daniel

-- 
https://www.domob.eu/
OpenPGP: 1142 850E 6DFF 65BA 63D6  88A8 B249 2AC4 A733 0737
Namecoin: id/domob -> https://nameid.org/?name=domob
--
3.6.0: Bar-Pri-Ran-Rog-Sam-Val-Wiz
To go: Arc-Cav-Hea-Kni-Mon-Tou

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]