kakoune

Fork of kakoune, an acceptable text editor
git clone git://git.laack.co/kakoune.git
Log | Files | Refs

exception.hh (697B)


      1 #ifndef exception_hh_INCLUDED
      2 #define exception_hh_INCLUDED
      3 
      4 #include "string.hh"
      5 
      6 namespace Kakoune
      7 {
      8 
      9 struct exception
     10 {
     11     virtual ~exception() = default;
     12     virtual StringView what() const;
     13 };
     14 
     15 struct runtime_error : exception
     16 {
     17     runtime_error(String what)
     18         : m_what(std::move(what)) {}
     19 
     20     StringView what() const override { return m_what; }
     21     void set_what(String what) { m_what = std::move(what); }
     22 
     23 private:
     24     String m_what;
     25 };
     26 
     27 struct failure : runtime_error
     28 {
     29     using runtime_error::runtime_error;
     30 };
     31 
     32 struct cancel : runtime_error
     33 {
     34     cancel() : runtime_error("cancellation requested") {}
     35 };
     36 
     37 struct logic_error : exception
     38 {
     39 };
     40 
     41 }
     42 
     43 #endif // exception_hh_INCLUDED