blob: 49ce40bb6ee9dbbae7de953897d42a336a73d012 [file] [log] [blame]
Christopher Wiley80fd1202015-11-22 17:12:37 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package android.os;
17
Aurimas Liutikas4d1699d2019-08-28 13:01:05 -070018import android.annotation.NonNull;
paulhu79b380c2019-03-15 17:17:02 +080019import android.annotation.Nullable;
Lorenzo Colittia27da722019-01-22 17:11:01 +090020import android.annotation.SystemApi;
21
Christopher Wiley80fd1202015-11-22 17:12:37 -080022/**
23 * An exception specific to a service.
24 *
25 * <p>This exception includes an error code specific to the throwing
26 * service. This is mostly used by system services to indicate
Eino-Ville Talvala5d2d7782015-12-17 16:50:50 -080027 * domain specific error conditions.</p>
28 *
29 * <p>Since these exceptions are designed to be passed through Binder
30 * interfaces, and to be generated by native-code Binder services,
31 * they do not support exception chaining.</p>
Christopher Wiley80fd1202015-11-22 17:12:37 -080032 *
33 * @hide
34 */
Lorenzo Colittia27da722019-01-22 17:11:01 +090035@SystemApi
Christopher Wiley80fd1202015-11-22 17:12:37 -080036public class ServiceSpecificException extends RuntimeException {
37 public final int errorCode;
38
paulhu79b380c2019-03-15 17:17:02 +080039 public ServiceSpecificException(int errorCode, @Nullable String message) {
Christopher Wiley80fd1202015-11-22 17:12:37 -080040 super(message);
41 this.errorCode = errorCode;
42 }
43
Eino-Ville Talvala5d2d7782015-12-17 16:50:50 -080044 public ServiceSpecificException(int errorCode) {
Christopher Wiley80fd1202015-11-22 17:12:37 -080045 this.errorCode = errorCode;
46 }
Jeff Sharkey447a3ac2016-12-12 10:15:37 -070047
Aurimas Liutikas4d1699d2019-08-28 13:01:05 -070048 @NonNull
Jeff Sharkey447a3ac2016-12-12 10:15:37 -070049 @Override
50 public String toString() {
51 return super.toString() + " (code " + errorCode + ")";
52 }
Christopher Wiley80fd1202015-11-22 17:12:37 -080053}