• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://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,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef STORAGE_SERVICE_UTILS_ERRNO_H
16 #define STORAGE_SERVICE_UTILS_ERRNO_H
17 
18 #include <sys/types.h>
19 #include <unordered_map>
20 
21 namespace OHOS {
22 constexpr int32_t E_ERR = -1;
23 constexpr int32_t STORAGE_SERVICE_SYS_CAP_TAG = 13600000;
24 
25 enum ErrNo {
26     E_OK = 0,
27     E_PERMISSION_DENIED = 1,    // no permission
28     E_WRITE_DESCRIPTOR_ERR = 2, // ipc error
29     E_EXIST = 3,                // exist
30     E_WRONG_TYPE = 4,           // wrong file type
31     E_USER_STATE = 5,           // wrong user state
32     E_NON_EXIST = 6,            // no such item
33     E_PREPARE_DIR = 7,          // failed to prepare dir
34     E_DESTROY_DIR = 8,          // failed to destroy dir
35     E_MOUNT,                    // mount error
36     E_UMOUNT,                   // umount error
37     E_SET_POLICY,               // set policy error
38     E_USERID_RANGE,             // id out or range
39     E_VOL_STATE,                // volume state check fail
40     E_WAIT,                     // wait
41     E_NOT_SUPPORT,              // not support
42     E_SYS_CALL,                 // syscall error
43     E_NO_CHILD,                 // child not exist
44     E_WRITE_PARCEL_ERR,
45     E_WRITE_REPLY_ERR,
46     E_SA_IS_NULLPTR,
47     E_REMOTE_IS_NULLPTR,
48     E_SERVICE_IS_NULLPTR,
49     E_DEATH_RECIPIENT_IS_NULLPTR,
50     E_BUNDLEMGR_ERROR,
51     E_MEDIALIBRARY_ERROR,
52 };
53 
54 enum JsErrCode {
55     E_PERMISSION = 201,
56     E_PERMISSION_SYS = 202,
57     E_PARAMS = 401,
58     E_DEVICENOTSUPPORT = 801,
59     E_OSNOTSUPPORT = 901,
60     E_IPCSS = STORAGE_SERVICE_SYS_CAP_TAG + 1,
61     E_SUPPORTEDFS,
62     E_MOUNT_ERR,
63     E_UNMOUNT,
64     E_VOLUMESTATE,
65     E_PREPARE,
66     E_DELETE,
67     E_NOOBJECT,
68     E_OUTOFRANGE,
69 };
70 
71 const std::unordered_map<int32_t, int32_t> errCodeTable {
72     { E_PERMISSION_DENIED, E_PERMISSION },
73     { E_WRITE_DESCRIPTOR_ERR, E_IPCSS},
74     { E_EXIST, E_PREPARE},
75     { E_WRONG_TYPE, E_WRONG_TYPE},
76     { E_USER_STATE, E_USER_STATE},
77     { E_NON_EXIST, E_NOOBJECT},
78     { E_PREPARE_DIR, E_PREPARE_DIR},
79     { E_DESTROY_DIR, E_DESTROY_DIR},
80     { E_MOUNT, E_MOUNT_ERR},
81     { E_UMOUNT, E_UNMOUNT},
82     { E_SET_POLICY, E_SET_POLICY},
83     { E_USERID_RANGE, E_OUTOFRANGE},
84     { E_VOL_STATE, E_VOLUMESTATE},
85     { E_WAIT, E_VOLUMESTATE},
86     { E_NOT_SUPPORT, E_SUPPORTEDFS},
87     { E_SYS_CALL, E_UNMOUNT},
88     { E_NO_CHILD, E_NO_CHILD},
89     { E_WRITE_PARCEL_ERR, E_IPCSS},
90     { E_WRITE_REPLY_ERR, E_IPCSS},
91     { E_SA_IS_NULLPTR, E_IPCSS},
92     { E_REMOTE_IS_NULLPTR, E_IPCSS},
93     { E_SERVICE_IS_NULLPTR, E_IPCSS},
94     { E_DEATH_RECIPIENT_IS_NULLPTR, E_IPCSS},
95     { E_BUNDLEMGR_ERROR, E_IPCSS},
96     { E_MEDIALIBRARY_ERROR, E_IPCSS},
97 };
98 }
99 #endif // STORAGE_SERVICE_UTILS_ERRNO_H