blob: 0398d54269235f1b83a28965abd34271b7d295a1 [file] [log] [blame]
Andrew Scull96517d82017-10-09 12:53:19 +01001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <nos/debug.h>
18
19#include <application.h>
20
21namespace nos {
22
23#define ErrorString_helper(x) \
24 case app_status::x: \
25 return #x;
26
27std::string StatusCodeString(uint32_t code) {
28 switch (code) {
29 ErrorString_helper(APP_SUCCESS)
30 ErrorString_helper(APP_ERROR_BOGUS_ARGS)
31 ErrorString_helper(APP_ERROR_INTERNAL)
32 ErrorString_helper(APP_ERROR_TOO_MUCH)
Andrew Scull3935b182017-10-11 16:02:39 +010033 ErrorString_helper(APP_ERROR_IO)
Andrew Scull96517d82017-10-09 12:53:19 +010034 ErrorString_helper(APP_ERROR_RPC)
Andrew Scull3fc6cfe2018-02-22 11:09:51 -080035 ErrorString_helper(APP_ERROR_CHECKSUM)
36 ErrorString_helper(APP_ERROR_BUSY)
Andrew Scull4ecaac12018-07-18 15:17:33 +010037 ErrorString_helper(APP_ERROR_TIMEOUT)
Andrew Scull96517d82017-10-09 12:53:19 +010038 default:
39 if (code >= APP_LINE_NUMBER_BASE && code < MAX_APP_STATUS) {
40 return "APP_LINE_NUMBER " + std::to_string(code - APP_LINE_NUMBER_BASE);
41 }
42 if (code >= APP_SPECIFIC_ERROR && code < APP_LINE_NUMBER_BASE) {
43 return "APP_SPECIFIC_ERROR " + std::to_string(APP_LINE_NUMBER_BASE) +
44 " + " + std::to_string(code - APP_LINE_NUMBER_BASE);
45 }
46
47 return "unknown";
48 }
49}
50
51} // namespace nos