1 /* 2 * Copyright (C) 2019 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 #include <utils/Errors.h> 17 18 #include <string.h> 19 20 namespace android { 21 statusToString(status_t s)22std::string statusToString(status_t s) { 23 #define STATUS_CASE(STATUS) \ 24 case STATUS: \ 25 return #STATUS 26 27 switch (s) { 28 STATUS_CASE(OK); 29 STATUS_CASE(UNKNOWN_ERROR); 30 STATUS_CASE(NO_MEMORY); 31 STATUS_CASE(INVALID_OPERATION); 32 STATUS_CASE(BAD_VALUE); 33 STATUS_CASE(BAD_TYPE); 34 STATUS_CASE(NAME_NOT_FOUND); 35 STATUS_CASE(PERMISSION_DENIED); 36 STATUS_CASE(NO_INIT); 37 STATUS_CASE(ALREADY_EXISTS); 38 STATUS_CASE(DEAD_OBJECT); 39 STATUS_CASE(FAILED_TRANSACTION); 40 STATUS_CASE(BAD_INDEX); 41 STATUS_CASE(NOT_ENOUGH_DATA); 42 STATUS_CASE(WOULD_BLOCK); 43 STATUS_CASE(TIMED_OUT); 44 STATUS_CASE(UNKNOWN_TRANSACTION); 45 STATUS_CASE(FDS_NOT_ALLOWED); 46 STATUS_CASE(UNEXPECTED_NULL); 47 #undef STATUS_CASE 48 } 49 50 return std::to_string(s) + " (" + strerror(-s) + ")"; 51 } 52 53 } // namespace android 54