From 6c825064eab7f0e261637852cf9254f6e3aadf51 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 13 Sep 2017 17:48:13 +0200 Subject: [PATCH] system/Error: add more "noexcept" --- src/system/Error.hxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/system/Error.hxx b/src/system/Error.hxx index 4d89e12c8..056bbd017 100644 --- a/src/system/Error.hxx +++ b/src/system/Error.hxx @@ -40,7 +40,8 @@ template static inline std::system_error -FormatSystemError(std::error_code code, const char *fmt, Args&&... args) +FormatSystemError(std::error_code code, const char *fmt, + Args&&... args) noexcept { char buffer[1024]; snprintf(buffer, sizeof(buffer), fmt, std::forward(args)...); @@ -52,21 +53,21 @@ FormatSystemError(std::error_code code, const char *fmt, Args&&... args) #include static inline std::system_error -MakeLastError(DWORD code, const char *msg) +MakeLastError(DWORD code, const char *msg) noexcept { return std::system_error(std::error_code(code, std::system_category()), msg); } static inline std::system_error -MakeLastError(const char *msg) +MakeLastError(const char *msg) noexcept { return MakeLastError(GetLastError(), msg); } template static inline std::system_error -FormatLastError(DWORD code, const char *fmt, Args&&... args) +FormatLastError(DWORD code, const char *fmt, Args&&... args) noexcept { char buffer[512]; const auto end = buffer + sizeof(buffer); @@ -84,7 +85,7 @@ FormatLastError(DWORD code, const char *fmt, Args&&... args) template static inline std::system_error -FormatLastError(const char *fmt, Args&&... args) +FormatLastError(const char *fmt, Args&&... args) noexcept { return FormatLastError(GetLastError(), fmt, std::forward(args)...); @@ -104,7 +105,7 @@ FormatLastError(const char *fmt, Args&&... args) * @see https://stackoverflow.com/questions/28746372/system-error-categories-and-standard-system-error-codes */ static inline const std::error_category & -ErrnoCategory() +ErrnoCategory() noexcept { #ifdef WIN32 /* on Windows, the generic_category() is used for errno @@ -118,21 +119,21 @@ ErrnoCategory() } static inline std::system_error -MakeErrno(int code, const char *msg) +MakeErrno(int code, const char *msg) noexcept { return std::system_error(std::error_code(code, ErrnoCategory()), msg); } static inline std::system_error -MakeErrno(const char *msg) +MakeErrno(const char *msg) noexcept { return MakeErrno(errno, msg); } template static inline std::system_error -FormatErrno(int code, const char *fmt, Args&&... args) +FormatErrno(int code, const char *fmt, Args&&... args) noexcept { char buffer[512]; snprintf(buffer, sizeof(buffer), @@ -142,7 +143,7 @@ FormatErrno(int code, const char *fmt, Args&&... args) template static inline std::system_error -FormatErrno(const char *fmt, Args&&... args) +FormatErrno(const char *fmt, Args&&... args) noexcept { return FormatErrno(errno, fmt, std::forward(args)...); }