1e9297d28Sopenharmony_ci/*
2e9297d28Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3e9297d28Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e9297d28Sopenharmony_ci * you may not use this file except in compliance with the License.
5e9297d28Sopenharmony_ci * You may obtain a copy of the License at
6e9297d28Sopenharmony_ci *
7e9297d28Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e9297d28Sopenharmony_ci *
9e9297d28Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e9297d28Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e9297d28Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e9297d28Sopenharmony_ci * See the License for the specific language governing permissions and
13e9297d28Sopenharmony_ci * limitations under the License.
14e9297d28Sopenharmony_ci */
15e9297d28Sopenharmony_ci
16e9297d28Sopenharmony_ci#ifndef ROSEN_COMMON_GRAPHIC_ERROR_H
17e9297d28Sopenharmony_ci#define ROSEN_COMMON_GRAPHIC_ERROR_H
18e9297d28Sopenharmony_ci
19e9297d28Sopenharmony_ci#ifdef __cplusplus
20e9297d28Sopenharmony_ci#include <cstdint>
21e9297d28Sopenharmony_ci#include <cstring>
22e9297d28Sopenharmony_ci#include <map>
23e9297d28Sopenharmony_ci#include <string>
24e9297d28Sopenharmony_ci
25e9297d28Sopenharmony_cinamespace OHOS {
26e9297d28Sopenharmony_cinamespace Rosen {
27e9297d28Sopenharmony_ci#endif
28e9297d28Sopenharmony_ci
29e9297d28Sopenharmony_ci// Graphic Rosen Error, number just find fast, it may change
30e9297d28Sopenharmony_cienum RosenError : int32_t {
31e9297d28Sopenharmony_ci    ROSEN_ERROR_OK                    = 0,
32e9297d28Sopenharmony_ci
33e9297d28Sopenharmony_ci    // 400 BAD_REQUEST
34e9297d28Sopenharmony_ci    ROSEN_ERROR_INVALID_ARGUMENTS     = 40001000,
35e9297d28Sopenharmony_ci
36e9297d28Sopenharmony_ci    // 403 FORBIDDEN
37e9297d28Sopenharmony_ci    ROSEN_ERROR_NO_PERMISSION         = 40301000,
38e9297d28Sopenharmony_ci
39e9297d28Sopenharmony_ci    // 404 NOT_FOUND
40e9297d28Sopenharmony_ci    ROSEN_ERROR_CONNOT_CONNECT_SAMGR  = 40401000,
41e9297d28Sopenharmony_ci    ROSEN_ERROR_CONNOT_CONNECT_SERVER = 40402000,
42e9297d28Sopenharmony_ci    ROSEN_ERROR_CONNOT_CONNECT_WESTON = 40403000,
43e9297d28Sopenharmony_ci
44e9297d28Sopenharmony_ci    // 406 NOT_ACCEPTABLE
45e9297d28Sopenharmony_ci    ROSEN_ERROR_NO_BUFFER             = 40601000,
46e9297d28Sopenharmony_ci    ROSEN_ERROR_NO_ENTRY              = 40602000,
47e9297d28Sopenharmony_ci    ROSEN_ERROR_OUT_OF_RANGE          = 40603000,
48e9297d28Sopenharmony_ci
49e9297d28Sopenharmony_ci    // 412 PRECONDITION_FAILED
50e9297d28Sopenharmony_ci    ROSEN_ERROR_INVALID_OPERATING     = 41201000,
51e9297d28Sopenharmony_ci    ROSEN_ERROR_NO_CONSUMER           = 41202000,
52e9297d28Sopenharmony_ci    ROSEN_ERROR_NOT_INIT              = 41203000,
53e9297d28Sopenharmony_ci    ROSEN_ERROR_TYPE_ERROR            = 41204000,
54e9297d28Sopenharmony_ci    ROSEN_ERROR_DESTROYED_OBJECT      = 41205000,
55e9297d28Sopenharmony_ci
56e9297d28Sopenharmony_ci    // 500 INTERNAL ERROR
57e9297d28Sopenharmony_ci    ROSEN_ERROR_API_FAILED            = 50001000,
58e9297d28Sopenharmony_ci    ROSEN_ERROR_INTERNAL              = 50002000,
59e9297d28Sopenharmony_ci    ROSEN_ERROR_NO_MEM                = 50003000,
60e9297d28Sopenharmony_ci    ROSEN_ERROR_PROXY_NOT_INCLUDE     = 50004000,
61e9297d28Sopenharmony_ci    ROSEN_ERROR_SERVER_ERROR          = 50005000,
62e9297d28Sopenharmony_ci
63e9297d28Sopenharmony_ci    // 501 NOT_IMPLEMENTED
64e9297d28Sopenharmony_ci    ROSEN_ERROR_NOT_IMPLEMENT         = 50101000,
65e9297d28Sopenharmony_ci    ROSEN_ERROR_NOT_SUPPORT           = 50102000,
66e9297d28Sopenharmony_ci
67e9297d28Sopenharmony_ci    // 504 GATEWAY ERROR
68e9297d28Sopenharmony_ci    ROSEN_ERROR_BINDER                = 50401000,
69e9297d28Sopenharmony_ci};
70e9297d28Sopenharmony_ci
71e9297d28Sopenharmony_ci#ifdef __cplusplus
72e9297d28Sopenharmony_cistatic const std::map<RosenError, std::string> RosenErrorStrs = {
73e9297d28Sopenharmony_ci    {ROSEN_ERROR_OK,                    "<200 ok>"},
74e9297d28Sopenharmony_ci    {ROSEN_ERROR_INVALID_ARGUMENTS,     "<400 invalid arguments>"},
75e9297d28Sopenharmony_ci    {ROSEN_ERROR_NO_PERMISSION,         "<403 no permission>"},
76e9297d28Sopenharmony_ci    {ROSEN_ERROR_CONNOT_CONNECT_SAMGR,  "<404 connot connect to samgr>"},
77e9297d28Sopenharmony_ci    {ROSEN_ERROR_CONNOT_CONNECT_SERVER, "<404 connot connect to server>"},
78e9297d28Sopenharmony_ci    {ROSEN_ERROR_CONNOT_CONNECT_WESTON, "<404 connot connect to weston>"},
79e9297d28Sopenharmony_ci    {ROSEN_ERROR_NO_BUFFER,             "<406 no buffer>"},
80e9297d28Sopenharmony_ci    {ROSEN_ERROR_NO_ENTRY,              "<406 no entry>"},
81e9297d28Sopenharmony_ci    {ROSEN_ERROR_OUT_OF_RANGE,          "<406 out of range>"},
82e9297d28Sopenharmony_ci    {ROSEN_ERROR_INVALID_OPERATING,     "<412 invalid operating>"},
83e9297d28Sopenharmony_ci    {ROSEN_ERROR_NO_CONSUMER,           "<412 no consumer>"},
84e9297d28Sopenharmony_ci    {ROSEN_ERROR_NOT_INIT,              "<412 not init>"},
85e9297d28Sopenharmony_ci    {ROSEN_ERROR_TYPE_ERROR,            "<412 type error>"},
86e9297d28Sopenharmony_ci    {ROSEN_ERROR_API_FAILED,            "<500 api call failed>"},
87e9297d28Sopenharmony_ci    {ROSEN_ERROR_INTERNAL,              "<500 internal error>"},
88e9297d28Sopenharmony_ci    {ROSEN_ERROR_NO_MEM,                "<500 no memory>"},
89e9297d28Sopenharmony_ci    {ROSEN_ERROR_PROXY_NOT_INCLUDE,     "<500 proxy not include>"},
90e9297d28Sopenharmony_ci    {ROSEN_ERROR_SERVER_ERROR,          "<500 server occur error>"},
91e9297d28Sopenharmony_ci    {ROSEN_ERROR_NOT_IMPLEMENT,         "<501 not implement>"},
92e9297d28Sopenharmony_ci    {ROSEN_ERROR_NOT_SUPPORT,           "<501 not support>"},
93e9297d28Sopenharmony_ci    {ROSEN_ERROR_BINDER,                "<504 binder occur error>"},
94e9297d28Sopenharmony_ci};
95e9297d28Sopenharmony_ci
96e9297d28Sopenharmony_ci// backstore error
97e9297d28Sopenharmony_cienum BSError : int32_t {
98e9297d28Sopenharmony_ci    BS_ERROR_OK = ROSEN_ERROR_OK,
99e9297d28Sopenharmony_ci    BS_ERROR_ERROR = ROSEN_ERROR_INTERNAL,
100e9297d28Sopenharmony_ci    BS_ERROR_BINDER_ERROR = ROSEN_ERROR_BINDER,
101e9297d28Sopenharmony_ci    BS_ERROR_NULLPTR = ROSEN_ERROR_INVALID_ARGUMENTS,
102e9297d28Sopenharmony_ci    BS_ERROR_NO_ENTRY = ROSEN_ERROR_NO_ENTRY,
103e9297d28Sopenharmony_ci    BS_ERROR_INVALID_OPERATING = ROSEN_ERROR_INVALID_OPERATING,
104e9297d28Sopenharmony_ci    BS_ERROR_NO_BUFFER = ROSEN_ERROR_NO_BUFFER,
105e9297d28Sopenharmony_ci    BS_ERROR_INVALID_PARAM = ROSEN_ERROR_INVALID_ARGUMENTS,
106e9297d28Sopenharmony_ci    BS_ERROR_INIT = ROSEN_ERROR_INTERNAL,
107e9297d28Sopenharmony_ci    BS_ERROR_NOMEM = ROSEN_ERROR_NO_MEM,
108e9297d28Sopenharmony_ci    BS_ERROR_API_FAILED = ROSEN_ERROR_API_FAILED,
109e9297d28Sopenharmony_ci    BS_ERROR_NOT_SUPPORT = ROSEN_ERROR_NOT_SUPPORT,
110e9297d28Sopenharmony_ci    BS_ERROR_OUT_OF_RANGE = ROSEN_ERROR_OUT_OF_RANGE,
111e9297d28Sopenharmony_ci    BS_ERROR_TYPE_ERROR = ROSEN_ERROR_TYPE_ERROR,
112e9297d28Sopenharmony_ci    BS_ERROR_NO_CONSUMER = ROSEN_ERROR_NO_CONSUMER,
113e9297d28Sopenharmony_ci};
114e9297d28Sopenharmony_ci} // namespace Rosen
115e9297d28Sopenharmony_ci} // namespace OHOS
116e9297d28Sopenharmony_ci#endif // __cplusplus
117e9297d28Sopenharmony_ci
118e9297d28Sopenharmony_ci#endif // INTERFACES_INNERKITS_COMMON_GRAPHIC_COMMON_H
119