Home | History | Annotate | Download | only in libnos
      1 /*
      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 
     21 namespace nos {
     22 
     23 #define ErrorString_helper(x) \
     24     case app_status::x: \
     25       return #x;
     26 
     27 std::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)
     33     ErrorString_helper(APP_ERROR_IO)
     34     ErrorString_helper(APP_ERROR_RPC)
     35     default:
     36       if (code >= APP_LINE_NUMBER_BASE && code < MAX_APP_STATUS) {
     37         return "APP_LINE_NUMBER " + std::to_string(code - APP_LINE_NUMBER_BASE);
     38       }
     39       if (code >= APP_SPECIFIC_ERROR && code < APP_LINE_NUMBER_BASE) {
     40         return "APP_SPECIFIC_ERROR " + std::to_string(APP_LINE_NUMBER_BASE) +
     41             " + " + std::to_string(code - APP_LINE_NUMBER_BASE);
     42       }
     43 
     44       return "unknown";
     45   }
     46 }
     47 
     48 }  // namespace nos
     49