| 1 | // | 
|---|
| 2 | // Error.h | 
|---|
| 3 | // | 
|---|
| 4 | // Library: Foundation | 
|---|
| 5 | // Package: Core | 
|---|
| 6 | // Module:  Error | 
|---|
| 7 | // | 
|---|
| 8 | // Definition of the Error class. | 
|---|
| 9 | // | 
|---|
| 10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. | 
|---|
| 11 | // and Contributors. | 
|---|
| 12 | // | 
|---|
| 13 | // SPDX-License-Identifier:	BSL-1.0 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | #ifndef Foundation_Error_INCLUDED | 
|---|
| 18 | #define Foundation_Error_INCLUDED | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | #include "Poco/Foundation.h" | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 | namespace Poco { | 
|---|
| 25 |  | 
|---|
| 26 |  | 
|---|
| 27 | class Foundation_API Error | 
|---|
| 28 | /// The Error class provides utility functions | 
|---|
| 29 | /// for error reporting. | 
|---|
| 30 | { | 
|---|
| 31 | public: | 
|---|
| 32 |  | 
|---|
| 33 | #ifdef POCO_OS_FAMILY_WINDOWS | 
|---|
| 34 | static Poco::UInt32 last(); | 
|---|
| 35 | /// Utility function returning the last error. | 
|---|
| 36 |  | 
|---|
| 37 | static std::string getMessage(Poco::UInt32 errorCode); | 
|---|
| 38 | /// Utility function translating numeric error code to string. | 
|---|
| 39 | #else | 
|---|
| 40 | static int last(); | 
|---|
| 41 | /// Utility function returning the last error. | 
|---|
| 42 |  | 
|---|
| 43 | static std::string getMessage(int errorCode); | 
|---|
| 44 | /// Utility function translating numeric error code to string. | 
|---|
| 45 |  | 
|---|
| 46 | private: | 
|---|
| 47 | // Helper function to adapt the result from glibc's variant of strerror_r. | 
|---|
| 48 | static const char* strerror_result(int, const char* s) { return s; } | 
|---|
| 49 | static const char* strerror_result(const char* s, const char*) { return s; } | 
|---|
| 50 | #endif | 
|---|
| 51 | }; | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | } // namespace Poco | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|
| 57 | #endif // Foundation_Error_INCLUDED | 
|---|
| 58 |  | 
|---|