blob: 9adbeab5610a3c2bcc017e0d07003fff411ffd05 [file] [log] [blame]
Wyatt Hepler421a8102020-01-13 11:30:58 -08001// Copyright 2020 The Pigweed Authors
Alexei Frolov1a82c142019-10-31 17:37:12 -07002//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
Wyatt Hepler1a960942019-11-26 14:13:38 -08004// use this file except in compliance with the License. You may obtain a copy of
5// the License at
Alexei Frolov1a82c142019-10-31 17:37:12 -07006//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
Wyatt Hepler1a960942019-11-26 14:13:38 -080012// License for the specific language governing permissions and limitations under
13// the License.
Alexei Frolov1a82c142019-10-31 17:37:12 -070014
15#include "pw_status/status.h"
16
Alexei Frolov1a82c142019-10-31 17:37:12 -070017#define PW_CASE_RETURN_ENUM_STRING(value) \
Wyatt Hepler421a8102020-01-13 11:30:58 -080018 case PW_STATUS_##value: \
Alexei Frolov1a82c142019-10-31 17:37:12 -070019 return #value
20
Wyatt Hepler421a8102020-01-13 11:30:58 -080021extern "C" const char* pw_StatusString(pw_Status status) {
Wyatt Hepler421a8102020-01-13 11:30:58 -080022 switch (status) {
Alexei Frolov1a82c142019-10-31 17:37:12 -070023 PW_CASE_RETURN_ENUM_STRING(OK);
24 PW_CASE_RETURN_ENUM_STRING(CANCELLED);
25 PW_CASE_RETURN_ENUM_STRING(UNKNOWN);
26 PW_CASE_RETURN_ENUM_STRING(INVALID_ARGUMENT);
27 PW_CASE_RETURN_ENUM_STRING(DEADLINE_EXCEEDED);
28 PW_CASE_RETURN_ENUM_STRING(NOT_FOUND);
29 PW_CASE_RETURN_ENUM_STRING(ALREADY_EXISTS);
30 PW_CASE_RETURN_ENUM_STRING(PERMISSION_DENIED);
31 PW_CASE_RETURN_ENUM_STRING(RESOURCE_EXHAUSTED);
32 PW_CASE_RETURN_ENUM_STRING(FAILED_PRECONDITION);
33 PW_CASE_RETURN_ENUM_STRING(ABORTED);
34 PW_CASE_RETURN_ENUM_STRING(OUT_OF_RANGE);
35 PW_CASE_RETURN_ENUM_STRING(UNIMPLEMENTED);
36 PW_CASE_RETURN_ENUM_STRING(INTERNAL);
37 PW_CASE_RETURN_ENUM_STRING(UNAVAILABLE);
38 PW_CASE_RETURN_ENUM_STRING(DATA_LOSS);
39 PW_CASE_RETURN_ENUM_STRING(UNAUTHENTICATED);
40 default:
41 return "INVALID STATUS";
42 }
43}
44
45#undef PW_CASE_RETURN_ENUM_STRING