[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Capturing exception messages in octave C++ API
From: |
Kai Torben Ohlhus |
Subject: |
Re: Capturing exception messages in octave C++ API |
Date: |
Fri, 18 Oct 2019 11:08:15 +0900 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 |
On 10/17/19 4:11 PM, rupakrokade wrote:
> Thank you for your reply. I am using Octave 4.4.1 on a Debian 10 OS. I am
> not using octave development source. Currently, I get the error messages
> printed on the terminal even without any try-catch statements. How do I
> buffer these messages anyway? Any example code will help.
>
> Rupak
>
Please find an example attached. It is a modified version of the
embedded.cc example code in Octave which redirects std::cout and
std::cerr to an std::stringstream buffer, as described by good old
StackOverflow
https://stackoverflow.com/questions/5419356/redirect-stdout-stderr-to-a-string
and as it was already suggested by jwe.
I tested it with Octave 4.4.1, but it should also work for Octave 5.1.0.
Anyways, the new interface of Octave dev can do this much cleaner and
easier in a one or two liner. Thanks for this jwe!
HTH,
Kai
embedded.cc
Description: Text Data