Skip to content

Commit a35d647

Browse files
committed
change to const map
1 parent ac67556 commit a35d647

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/cpr/error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ enum class ErrorCode {
9090
UNKNOWN_ERROR = 1000,
9191
};
9292

93-
inline std::unordered_map<ErrorCode, std::string> error_code_to_string_mapping = {{ErrorCode::OK, "OK"},
93+
inline const std::unordered_map<ErrorCode, std::string> error_code_to_string_mapping = {{ErrorCode::OK, "OK"},
9494
{ErrorCode::UNSUPPORTED_PROTOCOL, "UNSUPPORTED_PROTOCOL"},
9595
{ErrorCode::FAILED_INIT, "FAILED_INIT"},
9696
{ErrorCode::URL_MALFORMAT, "URL_MALFORMAT"},
@@ -176,7 +176,7 @@ class Error {
176176

177177
namespace std {
178178
inline std::string to_string(const cpr::ErrorCode& code) {
179-
return cpr::error_code_to_string_mapping[code];
179+
return cpr::error_code_to_string_mapping.at(code);
180180
}
181181
} // namespace std
182182

0 commit comments

Comments
 (0)