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 21:13:01 -0700

On 04/13/2019 09:00 AM, address@hidden wrote:
Subject:
Re: try/catch not swallowing errors
From:
Daniel Kraft <address@hidden>
Date:
04/13/2019 08:24 AM
To:
address@hidden
List-Post:
<mailto:address@hidden>
Precedence:
list
MIME-Version:
1.0
References:
<address@hidden> <address@hidden>
In-Reply-To:
<address@hidden>
Message-ID:
<address@hidden>
Content-Type:
multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4njGAyKc9Dlw0AISOmhhuGmoPJzBm2xIH"
Message:
2

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.

I verified with a .oct file as well and also got no printed error.

        
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.
It must be something else in either the parallel or the struct package.  I tried to install the parallel package, but it required struct, and I was unable to install struct.

CXXFLAGS="-O2 -pipe -Wno-deprecated-declarations" /usr/local/bin/mkoctfile-5.1.0 --verbose -c error-helpers.cc
g++ -c  -fPIC -I/usr/local/include/octave-5.1.0/octave/.. -I/usr/local/include/octave-5.1.0/octave -I/usr/local/include  -pthread -fopenmp -O2 -pipe -Wno-deprecated-declarations    error-helpers.cc -o error-helpers.o
In file included from error-helpers.cc:22:0:
error-helpers.h:31:22: error: ‘octave_execution_exception’ does not name a type; did you mean ‘make_execution_exception’?
 void c_verror (const octave_execution_exception&, const char *, ...);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
                      make_execution_exception
error-helpers.cc:36:17: error: ‘octave_execution_exception’ does not name a type; did you mean ‘make_execution_exception’?
 c_verror (const octave_execution_exception&, const char *fmt, ...)
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
                 make_execution_exception
error-helpers.cc: In function ‘void _p_error(const char*, ...)’:
error-helpers.cc:60:8: error: ‘cerr’ is not a member of ‘std’
   std::cerr << msg;
        ^~~~
error-helpers.cc:60:8: note: suggested alternative: ‘errc’
   std::cerr << msg;
        ^~~~
        errc
Makefile:40: recipe for target 'error-helpers.o' failed
make: *** [error-helpers.o] Error 1
make: Leaving directory '/tmp/oct-gRP2yg/struct-1.0.15/src'

--Rik

reply via email to

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