X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FExceptionMessage.h;h=fea2efa9fdc452eafba1862bfc20a1c868b23d8b;hb=7d4292918e6bf66649229e2946e6ac0a30694494;hp=dc597c6547cf6d97ac69fc8e8d9bfbeff27b123a;hpb=801f807063eb97c381812fd4d452fd0662b23459;p=lyx.git diff --git a/src/support/ExceptionMessage.h b/src/support/ExceptionMessage.h index dc597c6547..fea2efa9fd 100644 --- a/src/support/ExceptionMessage.h +++ b/src/support/ExceptionMessage.h @@ -22,9 +22,26 @@ namespace lyx { namespace support { +/// LyX support three types of custom exceptions. In order of +/// increasing seriousness, these are: +/// +/// WarningException +/// Intended for unexpected situations that we do not expect +/// to compromise further operation. It has the effect of +/// aborting whatever operation in in process. +/// +/// BufferException +/// Intended for situations that indicate some problem with a +/// Buffer or its related data structures. The Buffer will be +/// closed, in emergency style. +/// +/// ErrorException +/// Intended for situations that indicate a global problem +/// with the program. It will lead to an emergency shutdown. enum ExceptionType { ErrorException, + BufferException, WarningException }; @@ -33,14 +50,17 @@ class ExceptionMessage: public std::exception { public: ExceptionMessage(ExceptionType type, docstring const & title, docstring const & details) - : exception((to_utf8(title) + "\n" + to_utf8(details)).c_str()), - type_(type), title_(title), details_(details) {} + : type_(type), title_(title), details_(details), + message_(to_utf8(title_ + docstring::value_type('\n') + details_)) {} - virtual ~ExceptionMessage() {} + virtual const char * what() const throw() { return message_.c_str(); } + virtual ~ExceptionMessage() throw() {} ExceptionType type_; docstring title_; docstring details_; + // Needed because we may not return a temporary in what(). + std::string message_; }; } // namespace support