1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.aws;
20
21 import org.jclouds.aws.domain.AWSError;
22 import org.jclouds.http.HttpCommand;
23 import org.jclouds.http.HttpResponse;
24 import org.jclouds.http.HttpResponseException;
25
26
27
28
29
30
31
32
33
34
35 public class AWSResponseException extends HttpResponseException {
36
37 private static final long serialVersionUID = 1L;
38
39 private AWSError error = new AWSError();
40
41 public AWSResponseException(HttpCommand command, HttpResponse response, AWSError error) {
42 super(String.format("request %s failed with code %s, error: %s", command.getCurrentRequest().getRequestLine(), response
43 .getStatusCode(), error.toString()), command, response);
44 this.setError(error);
45
46 }
47
48 public AWSResponseException(HttpCommand command, HttpResponse response, AWSError error,
49 Throwable cause) {
50 super(String.format("request %1$s failed with error: %2$s", command.getCurrentRequest().getRequestLine(), error
51 .toString()), command, response, cause);
52 this.setError(error);
53
54 }
55
56 public AWSResponseException(String message, HttpCommand command, HttpResponse response,
57 AWSError error) {
58 super(message, command, response);
59 this.setError(error);
60
61 }
62
63 public AWSResponseException(String message, HttpCommand command, HttpResponse response,
64 AWSError error, Throwable cause) {
65 super(message, command, response, cause);
66 this.setError(error);
67
68 }
69
70 public void setError(AWSError error) {
71 this.error = error;
72 }
73
74 public AWSError getError() {
75 return error;
76 }
77
78 }