Home Help Center

Can user selfdefine exception overload operator

sobersober Member sober dingOrganization: buptProject: net security mangement ✭✭
Hi,

As described in the title , I want to get details of the exception ,like the error file and error line ,I see in the generated .h it has no operator<<, how can I get this ,can you give some suggestions?

Thank you .

Sober

Comments

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    In Ice/Exception.h, we define three ostream inserters:
    std::ostream& operator<<(std::ostream&, const LocalException&);
    std::ostream& operator<<(std::ostream&, const UserException&);
    std::ostream& operator<<(std::ostream&, const SystemException&);
    

    You can provide more specialized ostream inserters for derived exceptions, for example:
    std::ostream& operator<<(std::ostream&, const MyFavouriteException&);
    

    That inserter can do whatever you want it to do.

    Cheers,

    Michi.
  • sobersober Member sober dingOrganization: buptProject: net security mangement ✭✭
    3x

    thanks,Michi

    I'll try.

    Cheers,
    Sober
Sign In or Register to comment.