1 // Copyright (C) 2023 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 #[derive(Clone, Copy, PartialEq, Debug)] 15 pub(crate) enum ErrorCode { 16 ErrOk = 0, 17 IpcSizeTooLarge = 2, 18 ChannelNotOpen = 5, 19 Permission = 201, 20 SystemApi = 202, 21 ParameterCheck = 401, 22 FileOperationErr = 13400001, 23 Other = 13499999, 24 TaskEnqueueErr = 21900004, 25 TaskNotFound = 21900006, 26 TaskStateErr = 21900007, 27 } 28 29 #[cfg(test)] 30 mod test { 31 use super::*; 32 #[test] ut_enum_error_code()33 fn ut_enum_error_code() { 34 assert_eq!(ErrorCode::ErrOk as i32, 0); 35 assert_eq!(ErrorCode::IpcSizeTooLarge as i32, 2); 36 assert_eq!(ErrorCode::ChannelNotOpen as i32, 5); 37 assert_eq!(ErrorCode::Permission as i32, 201); 38 assert_eq!(ErrorCode::SystemApi as i32, 202); 39 assert_eq!(ErrorCode::ParameterCheck as i32, 401); 40 assert_eq!(ErrorCode::FileOperationErr as i32, 13400001); 41 assert_eq!(ErrorCode::Other as i32, 13499999); 42 assert_eq!(ErrorCode::TaskEnqueueErr as i32, 21900004); 43 assert_eq!(ErrorCode::TaskNotFound as i32, 21900006); 44 assert_eq!(ErrorCode::TaskStateErr as i32, 21900007); 45 } 46 } 47