Browse Source

Make `Exception` subclass `std::exception` instead of `std::runtime_error`.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
fe9fbf8e90
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      include/common.hpp

+ 9
- 3
include/common.hpp View File

@@ -157,9 +157,15 @@ DeferWrapper<F> deferWrapper(F f) {
#define DEFER(code) auto CONCAT(_defer_, __COUNTER__) = rack::deferWrapper([&]() code)


/** An exception explicitly thrown by Rack. */
struct Exception : std::runtime_error {
Exception(const std::string& msg) : std::runtime_error(msg) {}
/** An exception explicitly thrown by Rack or a Rack plugin.
Can be subclassed to throw/catch specific custom exceptions.
*/
struct Exception : std::exception {
std::string msg;
Exception(const std::string& msg) : msg(msg) {}
const char* what() const noexcept override {
return msg.c_str();
}
};




Loading…
Cancel
Save