aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/common/Exception.h11
-rw-r--r--src/common/Exception.cpp6
2 files changed, 8 insertions, 9 deletions
diff --git a/include/cru/common/Exception.h b/include/cru/common/Exception.h
index 06a10030..0aee871c 100644
--- a/include/cru/common/Exception.h
+++ b/include/cru/common/Exception.h
@@ -9,8 +9,7 @@ namespace cru {
#endif
class CRU_BASE_API Exception : public std::exception {
public:
- Exception();
- explicit Exception(String message);
+ explicit Exception(String message = {});
CRU_DEFAULT_COPY(Exception)
CRU_DEFAULT_MOVE(Exception)
@@ -40,9 +39,11 @@ class CRU_BASE_API TextEncodeException : public Exception {
class ErrnoException : public Exception {
public:
- ErrnoException() : ErrnoException(String{}) {}
- explicit ErrnoException(const String& message);
- ErrnoException(const String& message, int errno_code);
+ /**
+ * @brief will retrieve errno automatically.
+ */
+ explicit ErrnoException(String message = {});
+ ErrnoException(String message, int errno_code);
CRU_DELETE_COPY(ErrnoException)
CRU_DELETE_MOVE(ErrnoException)
diff --git a/src/common/Exception.cpp b/src/common/Exception.cpp
index e1e3e128..37fa0038 100644
--- a/src/common/Exception.cpp
+++ b/src/common/Exception.cpp
@@ -5,8 +5,6 @@
#include <cerrno>
namespace cru {
-Exception::Exception() {}
-
Exception::Exception(String message) : message_(std::move(message)) {}
Exception::~Exception() {}
@@ -28,10 +26,10 @@ void Exception::AppendMessage(std::optional<StringView> additional_message) {
if (additional_message) AppendMessage(*additional_message);
}
-ErrnoException::ErrnoException(const String& message)
+ErrnoException::ErrnoException(String message)
: ErrnoException(message, errno) {}
-ErrnoException::ErrnoException(const String& message, int errno_code)
+ErrnoException::ErrnoException(String message, int errno_code)
: Exception(Format(u"{}. Errno is {}.", message, errno_code)),
errno_code_(errno_code) {}
} // namespace cru