blob: dfb4d9b95c05c9d465408f3ac47ee311928ed1ad [file] [log] [blame]
Steven Moreland591cab82019-11-15 00:07:32 -08001/*
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
Hao Chenb3e19932023-05-31 14:18:59 -070018#include <string.h>
19
Steven Moreland591cab82019-11-15 00:07:32 -080020namespace android {
21
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
Steven Moreland1e8e49c2019-12-09 11:22:11 -080050 return std::to_string(s) + " (" + strerror(-s) + ")";
Steven Moreland591cab82019-11-15 00:07:32 -080051}
52
53} // namespace android