• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Android Open Source Project
2 //
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 package com.google.android.downloader;
16 
17 import java.io.IOException;
18 
19 /**
20  * An exception that occurred during creation or execution of a request; contains {@link
21  * ErrorDetails} for more detail on the error.
22  */
23 public final class RequestException extends IOException {
24   private final ErrorDetails errorDetails;
25 
RequestException(ErrorDetails errorDetails)26   public RequestException(ErrorDetails errorDetails) {
27     this.errorDetails = errorDetails;
28   }
29 
RequestException(ErrorDetails errorDetails, Throwable cause)30   public RequestException(ErrorDetails errorDetails, Throwable cause) {
31     super(cause);
32     this.errorDetails = errorDetails;
33   }
34 
RequestException(Throwable cause)35   public RequestException(Throwable cause) {
36     super(cause);
37     this.errorDetails = ErrorDetails.create(cause.getMessage());
38   }
39 
RequestException(String message)40   public RequestException(String message) {
41     super(message);
42     this.errorDetails = ErrorDetails.create(message);
43   }
44 
getErrorDetails()45   public ErrorDetails getErrorDetails() {
46     return errorDetails;
47   }
48 
49   @Override
getMessage()50   public String getMessage() {
51     return super.getMessage() + "; " + errorDetails;
52   }
53 }
54