diff options
author | Jack Lloyd <[email protected]> | 2018-11-23 18:38:14 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-11-23 18:38:14 -0500 |
commit | 761a7f36f708b44c7af1dc9387f324d509b4acf6 (patch) | |
tree | 43ee497eb84b98c1f1e04a7e60d95b531ba0a88a /src/lib/utils/http_util/http_util.h | |
parent | ae42de8433260a37360d60b0a21665e13c4a63e8 (diff) | |
parent | b909778857b3e0b7eb86ac26c818e5f25baaddbd (diff) |
Merge GH #1744 Make exception throws easier to debug
Diffstat (limited to 'src/lib/utils/http_util/http_util.h')
-rw-r--r-- | src/lib/utils/http_util/http_util.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/utils/http_util/http_util.h b/src/lib/utils/http_util/http_util.h index 9edd3d983..92a67e42b 100644 --- a/src/lib/utils/http_util/http_util.h +++ b/src/lib/utils/http_util/http_util.h @@ -20,6 +20,20 @@ namespace Botan { namespace HTTP { +/** +* HTTP_Error Exception +*/ +class BOTAN_PUBLIC_API(2,0) HTTP_Error final : public Exception + { + public: + explicit HTTP_Error(const std::string& msg) : + Exception("HTTP error " + msg) + {} + + ErrorType error_type() const noexcept override { return ErrorType::HttpError; } + + }; + class Response final { public: @@ -44,7 +58,7 @@ class Response final void throw_unless_ok() { if(status_code() != 200) - throw Exception("HTTP error: " + status_message()); + throw HTTP_Error(status_message()); } private: @@ -54,17 +68,6 @@ class Response final std::map<std::string, std::string> m_headers; }; -/** -* HTTP_Error Exception -*/ -class BOTAN_PUBLIC_API(2,0) HTTP_Error final : public Exception - { - public: - explicit HTTP_Error(const std::string& msg) : - Exception("HTTP error " + msg) - {} - }; - BOTAN_PUBLIC_API(2,0) std::ostream& operator<<(std::ostream& o, const Response& resp); typedef std::function<std::string (const std::string&, const std::string&)> http_exch_fn; |