1 /*
2 * Copyright (c) 2020 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
16 #include "util/abilityms_status.h"
17
18 #include "util/abilityms_log.h"
19
20 namespace OHOS {
AbilityMsStatus(StatusCode code,const char * key,const char * msg)21 AbilityMsStatus::AbilityMsStatus(StatusCode code, const char *key, const char *msg)
22 {
23 code_ = code;
24 if (key != nullptr) {
25 key_ = key;
26 }
27 if (msg != nullptr) {
28 state_ = msg;
29 }
30 }
31
LogStatus() const32 void AbilityMsStatus::LogStatus() const
33 {
34 std::string result;
35 switch (code_) {
36 case OK:
37 result = "success: ";
38 break;
39 case PERMISSION_DENIED:
40 result = "permission denied: ";
41 break;
42 case BMS_QUERY_NOT_FOUND:
43 result = "bms query not found: ";
44 break;
45 case ABILITY_TASK_ERROR:
46 result = "task " + key_ + " exec failure: ";
47 break;
48 case APP_TRANSACT_ERROR:
49 result = "app transanct failure: ";
50 break;
51 case LIFE_CYCLE_ILLEGAL:
52 result = "life cycle illegal: ";
53 break;
54 case PROCESS_ERROR:
55 result = "process exception: ";
56 break;
57 case NO_ACTIVE_ABILITY:
58 result = "no active ability when " + key_ + ": ";
59 break;
60 case ABILITY_HELP_ERROR:
61 result = "help failure: ";
62 break;
63 default:
64 break;
65 }
66 result += state_;
67 HILOG_ERROR(LOG_DOMAIN, "%s", result.c_str());
68 }
69 }
70