Remove default: switch cases to allow for compiler errors just in case new enum values are introduced

This commit is contained in:
2023-09-07 09:18:40 +02:00
parent 6ed0915d85
commit 405224bffe
2 changed files with 5 additions and 6 deletions

View File

@ -107,10 +107,9 @@ std::string toString(httpd_ws_type_t val)
case HTTPD_WS_TYPE_CLOSE: return "HTTPD_WS_TYPE_CLOSE"; break;
case HTTPD_WS_TYPE_PING: return "HTTPD_WS_TYPE_PING"; break;
case HTTPD_WS_TYPE_PONG: return "HTTPD_WS_TYPE_PONG"; break;
default:
ESP_LOGW(TAG, "Unknown httpd_ws_type_t(%i)", std::to_underlying(val));
return fmt::format("Unknown httpd_ws_type_t({})", std::to_underlying(val));
}
ESP_LOGW(TAG, "Unknown httpd_ws_type_t(%i)", std::to_underlying(val));
return fmt::format("Unknown httpd_ws_type_t({})", std::to_underlying(val));
}
} // namespace esphttpdutils

View File

@ -67,9 +67,6 @@ const char *toString(ResponseStatus status)
case ResponseStatus::TooManyRequests: return "429 Too Many Requests";
case ResponseStatus::RequestHeaderFieldsTooLarge: return "431 Request Header Fields Too Large";
case ResponseStatus::UnavailableForLegalReasons: return "451 Unavailable For Legal Reasons";
default:
ESP_LOGW(TAG, "unknown httpd_err_code_t(%i)", std::to_underlying(status));
[[fallthrough]];
case ResponseStatus::InternalServerError: return "500 Internal Server Error";
case ResponseStatus::NotImplemented: return "501 Not Implemented";
case ResponseStatus::BadGateway: return "502 Bad Gateway";
@ -82,6 +79,9 @@ const char *toString(ResponseStatus status)
case ResponseStatus::NotExtended: return "510 Not Extended";
case ResponseStatus::NetworkAuthenticationRequired: return "511 Network Authentication Required";
}
ESP_LOGW(TAG, "unknown httpd_err_code_t(%i)", std::to_underlying(status));
return "500 Internal Server Error";
}
} // namespace esphttpdutils