Allen Webb | fbf534f | 2017-09-14 14:29:00 -0700 | [diff] [blame^] | 1 | #include <nos/NuggetClient.h> |
| 2 | |
| 3 | #include <application.h> |
| 4 | |
| 5 | namespace nos { |
| 6 | |
| 7 | #define ErrorString_helper(x) \ |
| 8 | case app_status::x: \ |
| 9 | return #x; |
| 10 | |
| 11 | std::string NuggetClient::StatusCodeString(uint32_t code) { |
| 12 | switch (code) { |
| 13 | ErrorString_helper(APP_SUCCESS) |
| 14 | ErrorString_helper(APP_ERROR_BOGUS_ARGS) |
| 15 | ErrorString_helper(APP_ERROR_INTERNAL) |
| 16 | ErrorString_helper(APP_ERROR_TOO_MUCH) |
| 17 | ErrorString_helper(APP_ERROR_RPC) |
| 18 | default: |
| 19 | if (code >= APP_LINE_NUMBER_BASE && code < MAX_APP_STATUS) { |
| 20 | return "APP_LINE_NUMBER " + std::to_string(code - APP_LINE_NUMBER_BASE); |
| 21 | } |
| 22 | if (code >= APP_SPECIFIC_ERROR && code < APP_LINE_NUMBER_BASE) { |
| 23 | return "APP_SPECIFIC_ERROR " + std::to_string(APP_LINE_NUMBER_BASE) + |
| 24 | " + " + std::to_string(code - APP_LINE_NUMBER_BASE); |
| 25 | } |
| 26 | |
| 27 | return "unknown"; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | } // namespace nos |