| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ICUError_h |
| 6 #define ICUError_h |
| 7 |
| 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/Assertions.h" |
| 11 #include <unicode/utypes.h> |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 // ICUError provides the unified way to handle ICU errors in Blink. |
| 16 class PLATFORM_EXPORT ICUError { |
| 17 STACK_ALLOCATED(); |
| 18 |
| 19 public: |
| 20 ~ICUError() { crashIfCritical(); } |
| 21 |
| 22 UErrorCode* operator&() { return &m_error; } |
| 23 operator UErrorCode() const { return m_error; } |
| 24 |
| 25 // Crash the renderer in the appropriate way if critical failure occurred. |
| 26 void crashIfCritical(); |
| 27 |
| 28 private: |
| 29 UErrorCode m_error = U_ZERO_ERROR; |
| 30 |
| 31 void handleFailure(); |
| 32 }; |
| 33 |
| 34 inline void ICUError::crashIfCritical() { |
| 35 if (U_FAILURE(m_error)) |
| 36 handleFailure(); |
| 37 } |
| 38 |
| 39 } // namespace blink |
| 40 |
| 41 #endif // ICUError_h |
| OLD | NEW |