180fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley/*
280fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * Copyright (C) 2015 The Android Open Source Project
380fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley *
480fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * Licensed under the Apache License, Version 2.0 (the "License");
580fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * you may not use this file except in compliance with the License.
680fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * You may obtain a copy of the License at
780fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley *
880fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley *      http://www.apache.org/licenses/LICENSE-2.0
980fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley *
1080fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * Unless required by applicable law or agreed to in writing, software
1180fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * distributed under the License is distributed on an "AS IS" BASIS,
1280fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1380fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * See the License for the specific language governing permissions and
1480fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * limitations under the License.
1580fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley */
1680fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wileypackage android.os;
1780fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley
1880fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley/**
1980fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * An exception specific to a service.
2080fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley *
2180fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * <p>This exception includes an error code specific to the throwing
2280fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * service.  This is mostly used by system services to indicate
235d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala * domain specific error conditions.</p>
245d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala *
255d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala * <p>Since these exceptions are designed to be passed through Binder
265d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala * interfaces, and to be generated by native-code Binder services,
275d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala * they do not support exception chaining.</p>
2880fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley *
2980fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley * @hide
3080fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley */
3180fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wileypublic class ServiceSpecificException extends RuntimeException {
3280fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley    public final int errorCode;
3380fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley
345d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala    public ServiceSpecificException(int errorCode, String message) {
3580fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley        super(message);
3680fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley        this.errorCode = errorCode;
3780fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley    }
3880fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley
395d2d7788f1759b0f3d2c057af0b3ea61b0354feeEino-Ville Talvala    public ServiceSpecificException(int errorCode) {
4080fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley        this.errorCode = errorCode;
4180fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley    }
42447a3ac16be99351c978c63107808f22e90c93f1Jeff Sharkey
43447a3ac16be99351c978c63107808f22e90c93f1Jeff Sharkey    @Override
44447a3ac16be99351c978c63107808f22e90c93f1Jeff Sharkey    public String toString() {
45447a3ac16be99351c978c63107808f22e90c93f1Jeff Sharkey        return super.toString() + " (code " + errorCode + ")";
46447a3ac16be99351c978c63107808f22e90c93f1Jeff Sharkey    }
4780fd1208b99fbb88f24faa5d55183cdbbdeb6777Christopher Wiley}
48