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: Rik
Subject: Re: try/catch not swallowing errors
Date: Sat, 13 Apr 2019 08:14:25 -0700

On 04/13/2019 05:38 AM, address@hidden wrote:
Subject:
Package showing error message even when caught
From:
Daniel Kraft <address@hidden>
Date:
04/13/2019 04:25 AM
To:
Octave Maintainers List <address@hidden>
List-Post:
<mailto:address@hidden>
Precedence:
list
MIME-Version:
1.0
Message-ID:
<address@hidden>
Content-Type:
multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ExXGeCnwrVMVHcBpTr1CB6XKd8uNy6r2J"
Message:
2

Hi!

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

If I use "error" directly in the try-catch block or even if using a
simple .oct file that just creates an error, then no message is printed
as expected.  But with the error generated from the parallel package's
"fload", it *is* shown.  So maybe it is related to the error being
thrown from out of a package?

I see this both on Octave 4.0.3 and 5.1.

Is this expected behaviour or a bug?
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.

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.

--Rik

reply via email to

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