exception using QL_Fail/QL_Require

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

exception using QL_Fail/QL_Require

杨 斯涵

Dear all, 


i have started a new project which depends on Quantlib and i have successfully built it (in fact i currently only use QL error macros, i.e QL_FAIL)


However whenever the compiler goes to QL_FAIL line,  it gives  exception message and stopped working:


First-chance exception at 0x7503b727 in project.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0041f424..
Unhandled exception at 0x771f15ee in project.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0041f424.

my code is very simple and i use QL_FAIL like:

if(!file.is_open())
{
     QL_FAIL(" the file does not exist");
}

I tried QL_Require it gives same error.

I see ERROR macro works fine in Quantlib but cant figure out what goes wrong in my project. Could someone pls give kindly some advise?

Thanks in advance,
Hans


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: exception using QL_Fail/QL_Require

Peter Caspers-4
Hi Hans,

QL_FAIL and QL_REQUIRE and the like throw an QuantLib::Error which extends std::exception. So what you see is perfectly expected, it is just the result from an uncaught exception. To see the error message you have to catch the exception and output it’s what()-result to std::clog or the like.

Kind Regards
Peter

On 14 Dec 2016, at 10:59, 杨 斯涵 <[hidden email]> wrote:

Dear all, 

i have started a new project which depends on Quantlib and i have successfully built it (in fact i currently only use QL error macros, i.e QL_FAIL)

However whenever the compiler goes to QL_FAIL line,  it gives  exception message and stopped working:

First-chance exception at 0x7503b727 in project.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0041f424..
Unhandled exception at 0x771f15ee in project.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0041f424.

my code is very simple and i use QL_FAIL like:

if(!file.is_open())
{
     QL_FAIL(" the file does not exist");
}

I tried QL_Require it gives same error.

I see ERROR macro works fine in Quantlib but cant figure out what goes wrong in my project. Could someone pls give kindly some advise?

Thanks in advance,
Hans

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

答复: exception using QL_Fail/QL_Require

杨 斯涵

Hi Peter, 


Thanks for your clarification.  I understand how it works now. 

In example folder i saw following code, which shows me how to use QL_FAIL properly.  

try{..

    } catch (QuantLib::Error e) {
        std::cout << "terminated with a ql exception: " << e.what()
                  << std::endl;
        return 1;
    } catch (std::exception e) {
        std::cout << "terminated with a general exception: " << e.what()
                  << std::endl;
        return 1;
    }

Regards,
Hans



发件人: Peter Caspers <[hidden email]>
发送时间: 2016年12月15日 1:17
收件人: 杨 斯涵
抄送: [hidden email]
主题: Re: [Quantlib-users] exception using QL_Fail/QL_Require
 
Hi Hans,

QL_FAIL and QL_REQUIRE and the like throw an QuantLib::Error which extends std::exception. So what you see is perfectly expected, it is just the result from an uncaught exception. To see the error message you have to catch the exception and output it’s what()-result to std::clog or the like.

Kind Regards
Peter

On 14 Dec 2016, at 10:59, 杨 斯涵 <[hidden email]> wrote:

Dear all, 

i have started a new project which depends on Quantlib and i have successfully built it (in fact i currently only use QL error macros, i.e QL_FAIL)

However whenever the compiler goes to QL_FAIL line,  it gives  exception message and stopped working:

First-chance exception at 0x7503b727 in project.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0041f424..
Unhandled exception at 0x771f15ee in project.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0041f424.

my code is very simple and i use QL_FAIL like:

if(!file.is_open())
{
     QL_FAIL(" the file does not exist");
}

I tried QL_Require it gives same error.

I see ERROR macro works fine in Quantlib but cant figure out what goes wrong in my project. Could someone pls give kindly some advise?

Thanks in advance,
Hans

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users