• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 "chre/util/system/error_util.h"
18 
19 #include "chre/util/system/chre_error_util.h"
20 
21 namespace chre {
22 
getChreErrorMessage(chreError error)23 const char *getChreErrorMessage(chreError error) {
24   switch (error) {
25     case CHRE_ERROR_NONE:
26       return "CHRE_ERROR_NONE";
27     case CHRE_ERROR:
28       return "CHRE_ERROR";
29     case CHRE_ERROR_INVALID_ARGUMENT:
30       return "CHRE_ERROR_INVALID_ARGUMENT";
31     case CHRE_ERROR_BUSY:
32       return "CHRE_ERROR_BUSY";
33     case CHRE_ERROR_NO_MEMORY:
34       return "CHRE_ERROR_NO_MEMORY";
35     case CHRE_ERROR_NOT_SUPPORTED:
36       return "CHRE_ERROR_NOT_SUPPORTED";
37     case CHRE_ERROR_TIMEOUT:
38       return "CHRE_ERROR_TIMEOUT";
39     case CHRE_ERROR_FUNCTION_DISABLED:
40       return "CHRE_ERROR_FUNCTION_DISABLED";
41     case CHRE_ERROR_REJECTED_RATE_LIMIT:
42       return "CHRE_ERROR_REJECTED_RATE_LIMIT";
43     case CHRE_ERROR_FUNCTION_RESTRICTED_TO_OTHER_CLIENT:
44       return "CHRE_ERROR_FUNCTION_RESTRICTED";
45     case CHRE_ERROR_OBSOLETE_REQUEST:
46       return "CHRE_ERROR_OBSOLETE_REQUEST";
47     case CHRE_ERROR_TRANSIENT:
48       return "CHRE_ERROR_TRANSIENT";
49     case CHRE_ERROR_PERMISSION_DENIED:
50       return "CHRE_ERROR_PERMISSION_DENIED";
51     case CHRE_ERROR_DESTINATION_NOT_FOUND:
52       return "CHRE_ERROR_DESTINATION_NOT_FOUND";
53       // If this assertion is hit, it is because a new CHRE error code was added
54       // and is not yet supported in this function. Add the new error code to
55       // this function and update this assertion to use the latest error code.
56       static_assert(CHRE_ERROR_SIZE == CHRE_ERROR_DESTINATION_NOT_FOUND + 1);
57     default:
58       return "CHRE_ERROR_UNKNOWN";
59   }
60 }
61 
62 }  // namespace chre
63