• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 package com.ohos.hapsigntool.error;
17 
18 /**
19  * Runtime exception for programs.
20  *
21  * @since 2021/12/28
22  */
23 public class CustomException extends RuntimeException {
24     private ERROR error;
25 
26     private String message;
27 
28     /**
29      * Create custom exception with params.
30      *
31      * @param error   Error enum to throw
32      * @param message Error msg to throw
33      */
CustomException(ERROR error, String message)34     CustomException(ERROR error, String message) {
35         super(message);
36         this.error = error;
37         this.message = message;
38     }
39 
40     /**
41      * Throw custom exception with params.
42      *
43      * @param error   Error enum to throw
44      * @param message Error msg to throw
45      */
throwException(ERROR error, String message)46     public static void throwException(ERROR error, String message) {
47         throw new CustomException(error, message);
48     }
49 
getError()50     public ERROR getError() {
51         return error;
52     }
53 
setError(ERROR error)54     public void setError(ERROR error) {
55         this.error = error;
56     }
57 
58     @Override
getMessage()59     public String getMessage() {
60         return message;
61     }
62 
setMessage(String message)63     public void setMessage(String message) {
64         this.message = message;
65     }
66 }
67