Exception.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Author: Juan Rada-Vilela, Ph.D.
  3. Copyright (C) 2010-2014 FuzzyLite Limited
  4. All rights reserved
  5. This file is part of fuzzylite.
  6. fuzzylite is free software: you can redistribute it and/or modify it under
  7. the terms of the GNU Lesser General Public License as published by the Free
  8. Software Foundation, either version 3 of the License, or (at your option)
  9. any later version.
  10. fuzzylite is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  13. for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
  16. fuzzylite™ is a trademark of FuzzyLite Limited.
  17. */
  18. #ifndef FL_EXCEPTION_H
  19. #define FL_EXCEPTION_H
  20. #include "fl/fuzzylite.h"
  21. #include <exception>
  22. #include <string>
  23. #include <vector>
  24. namespace fl {
  25. class FL_API Exception : public std::exception {
  26. protected:
  27. std::string _what;
  28. public:
  29. Exception(const std::string& what);
  30. Exception(const std::string& what, const std::string& file, int line,
  31. const std::string& function);
  32. virtual ~Exception() FL_INOEXCEPT FL_IOVERRIDE;
  33. FL_DEFAULT_COPY_AND_MOVE(Exception)
  34. virtual void setWhat(const std::string& what);
  35. virtual std::string getWhat() const;
  36. virtual const char* what() const FL_INOEXCEPT FL_IOVERRIDE;
  37. virtual void append(const std::string& whatElse);
  38. virtual void append(const std::string& file, int line, const std::string& function);
  39. virtual void append(const std::string& whatElse,
  40. const std::string& file, int line, const std::string& function);
  41. static std::string btCallStack();
  42. static void signalHandler(int signal);
  43. static void convertToException(int signal);
  44. static void terminate();
  45. static void catchException(const std::exception& exception);
  46. };
  47. }
  48. #endif /* FL_EXCEPTION_H */