1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit;
16
17 import java.net.URL;
18
19
20
21
22
23
24
25 public class FailingHttpStatusCodeException extends RuntimeException {
26
27 private final WebResponse response_;
28
29
30
31
32
33 public FailingHttpStatusCodeException(final WebResponse failingResponse) {
34 this(buildMessage(failingResponse), failingResponse);
35 }
36
37
38
39
40
41
42 public FailingHttpStatusCodeException(final String message, final WebResponse failingResponse) {
43 super(message);
44 response_ = failingResponse;
45 }
46
47
48
49
50
51 public int getStatusCode() {
52 return response_.getStatusCode();
53 }
54
55
56
57
58
59 public String getStatusMessage() {
60 return response_.getStatusMessage();
61 }
62
63 private static String buildMessage(final WebResponse failingResponse) {
64 final int code = failingResponse.getStatusCode();
65 final String msg = failingResponse.getStatusMessage();
66 final URL url = failingResponse.getWebRequest().getUrl();
67 return code + " " + msg + " for " + url;
68 }
69
70
71
72
73
74 public WebResponse getResponse() {
75 return response_;
76 }
77
78 }