Inflection
Morphology Inflection
Loading...
Searching...
No Matches
ICUException.hpp
1/*
2 * Copyright 2016-2024 Apple Inc. All rights reserved.
3 */
4#pragma once
5
6#include <inflection/exception/fwd.hpp>
7#include <inflection/exception/RuntimeException.hpp>
8#include <unicode/utypes.h>
9
15class INFLECTION_CLASS_API inflection::exception::ICUException
17{
18public:
22
23private:
24 UErrorCode status { U_ZERO_ERROR };
25
26public:
30 explicit ICUException(UErrorCode status);
34 ICUException(UErrorCode status, const std::u16string& message);
38 ~ICUException() override;
39
43 UErrorCode getError() const;
44
49 static void throwOnFailure(UErrorCode status);
55 static void throwOnFailure(UErrorCode status, const char16_t* message);
61 static void throwOnFailure(UErrorCode status, const std::u16string& message);
62};
63
64inline
65void
67{
68 if (U_FAILURE(status)) {
69 throw ICUException(status);
70 }
71}
72
73inline
74void
75inflection::exception::ICUException::throwOnFailure(UErrorCode status, const char16_t* message)
76{
77 if (U_FAILURE(status)) {
78 throw ICUException(status, message);
79 }
80}
81
82inline
83void
84inflection::exception::ICUException::throwOnFailure(UErrorCode status, const std::u16string& message)
85{
86 if (U_FAILURE(status)) {
87 throw ICUException(status, message);
88 }
89}
Used to indicate an error utilizing the ICU unicode library.
ICUException(UErrorCode status, const std::u16string &message)
static void throwOnFailure(UErrorCode status)
Used to indicate a generic exception occurring at runtime.
The C++ namespace for Inflection.
Definition fwd.hpp:11