blob: 3e0f6dae04d8bb2fd49e2cb231452560101f1d2a [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
18/**
19 * An exception specific to a service.
20 *
21 * <p>This exception includes an error code specific to the throwing
22 * service. This is mostly used by system services to indicate
Eino-Ville Talvala5d2d7782015-12-17 16:50:50 -080023 * domain specific error conditions.</p>
24 *
25 * <p>Since these exceptions are designed to be passed through Binder
26 * interfaces, and to be generated by native-code Binder services,
27 * they do not support exception chaining.</p>
Christopher Wiley80fd1202015-11-22 17:12:37 -080028 *
29 * @hide
30 */
31public class ServiceSpecificException extends RuntimeException {
32 public final int errorCode;
33
Eino-Ville Talvala5d2d7782015-12-17 16:50:50 -080034 public ServiceSpecificException(int errorCode, String message) {
Christopher Wiley80fd1202015-11-22 17:12:37 -080035 super(message);
36 this.errorCode = errorCode;
37 }
38
Eino-Ville Talvala5d2d7782015-12-17 16:50:50 -080039 public ServiceSpecificException(int errorCode) {
Christopher Wiley80fd1202015-11-22 17:12:37 -080040 this.errorCode = errorCode;
41 }
Jeff Sharkey447a3ac2016-12-12 10:15:37 -070042
43 @Override
44 public String toString() {
45 return super.toString() + " (code " + errorCode + ")";
46 }
Christopher Wiley80fd1202015-11-22 17:12:37 -080047}