From 0ec90627298b8b7bdc74a3993ca58f1dde14dc26 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 12 Oct 2023 17:47:30 +0800 Subject: ... --- src/platform/Exception.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/platform/Exception.cpp (limited to 'src/platform/Exception.cpp') diff --git a/src/platform/Exception.cpp b/src/platform/Exception.cpp new file mode 100644 index 00000000..7aef3b7f --- /dev/null +++ b/src/platform/Exception.cpp @@ -0,0 +1,44 @@ +#include "cru/platform/Exception.h" +#include "cru/common/Format.h" + +#include + +namespace cru::platform { +PlatformNotMatchException::PlatformNotMatchException( + String resource_platform, String target_platform, + std::optional additional_message) + : resource_platform_(std::move(resource_platform)), + target_platform_(std::move(target_platform)) { + SetMessage( + Format(u"Resource platform '{}' does not match target platform '{}'.", + resource_platform_, target_platform_)); + + AppendMessage(additional_message); +} + +PlatformNotMatchException::~PlatformNotMatchException() {} + +String PlatformNotMatchException::GetResourcePlatform() const { + return resource_platform_; +} + +String PlatformNotMatchException::GetTargetPlatform() const { + return target_platform_; +} + +PlatformUnsupportedException::PlatformUnsupportedException( + String platform, String operation, + std::optional additional_message) + : platform_(std::move(platform)), operation_(std::move(operation)) { + SetMessage(Format(u"Operation '{}' is not supported on platform '{}'.", + operation_, platform_)); + AppendMessage(additional_message); +} + +PlatformUnsupportedException::~PlatformUnsupportedException() {} + +String PlatformUnsupportedException::GetPlatform() const { return platform_; } + +String PlatformUnsupportedException::GetOperation() const { return operation_; } + +} // namespace cru::platform -- cgit v1.2.3