Skip to content

Commit a1f1c2d

Browse files
committed
simplify Exception constructors
1 parent 41ad69d commit a1f1c2d

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

src/main/java/org/htmlunit/cssparser/parser/CSSException.java

+33-20
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
*/
2020
public class CSSException extends RuntimeException {
2121

22-
/** Enum for error codes. */
22+
/**
23+
* Enum for error codes.
24+
*
25+
* @deprecated as of version 4.4.0
26+
*/
27+
@Deprecated
2328
protected enum ErrorCode {
2429
/** Unspecified. */
2530
UNSPECIFIED_ERR,
@@ -34,14 +39,20 @@ protected enum ErrorCode {
3439

3540
/**
3641
* Creates a new CSSException.
42+
*
43+
* @deprecated as of version 4.4.0; use {@link CSSException#CSSException(String, Exception)} instead
3744
*/
45+
@Deprecated
3846
public CSSException() {
3947
}
4048

4149
/**
4250
* Creates a new CSSException.
4351
* @param message the message
52+
*
53+
* @deprecated as of version 4.4.0; use {@link CSSException#CSSException(String, Exception)} instead
4454
*/
55+
@Deprecated
4556
public CSSException(final String message) {
4657
code_ = ErrorCode.UNSPECIFIED_ERR;
4758
message_ = message;
@@ -50,7 +61,10 @@ public CSSException(final String message) {
5061
/**
5162
* Creates a new CSSException with an embeded exception.
5263
* @param e the embeded exception.
64+
*
65+
* @deprecated as of version 4.4.0; use {@link CSSException#CSSException(String, Exception)} instead
5366
*/
67+
@Deprecated
5468
public CSSException(final Exception e) {
5569
code_ = ErrorCode.UNSPECIFIED_ERR;
5670
initCause(e);
@@ -59,7 +73,10 @@ public CSSException(final Exception e) {
5973
/**
6074
* Creates a new CSSException with a specific code.
6175
* @param code a the embeded exception.
76+
*
77+
* @deprecated as of version 4.4.0; use {@link CSSException#CSSException(String, Exception)} instead
6278
*/
79+
@Deprecated
6380
public CSSException(final ErrorCode code) {
6481
code_ = code;
6582
}
@@ -70,13 +87,27 @@ public CSSException(final ErrorCode code) {
7087
* @param code the specified code
7188
* @param message the message
7289
* @param e the embeded exception
90+
*
91+
* @deprecated as of version 4.4.0; use {@link CSSException#CSSException(String, Exception)} instead
7392
*/
93+
@Deprecated
7494
public CSSException(final ErrorCode code, final String message, final Exception e) {
7595
code_ = code;
7696
message_ = message;
7797
initCause(e);
7898
}
7999

100+
/**
101+
* Creates a new CSSException with an embeded exception and a specified
102+
* message.
103+
* @param message the message
104+
* @param e the cause
105+
*/
106+
public CSSException(final String message, final Exception e) {
107+
message_ = message;
108+
initCause(e);
109+
}
110+
80111
/**
81112
* {@inheritDoc}
82113
*
@@ -95,24 +126,6 @@ public String getMessage() {
95126
return getCause().getMessage();
96127
}
97128

98-
switch (code_) {
99-
case UNSPECIFIED_ERR:
100-
return "unknown error";
101-
case NOT_SUPPORTED_ERR:
102-
return "not supported";
103-
case SYNTAX_ERR:
104-
return "syntax error";
105-
default:
106-
return null;
107-
}
108-
}
109-
110-
/**
111-
* <p>getCode.</p>
112-
*
113-
* @return the error code for this exception.
114-
*/
115-
public ErrorCode getCode() {
116-
return code_;
129+
return "syntax error";
117130
}
118131
}

src/main/java/org/htmlunit/cssparser/parser/CSSParseException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public CSSParseException(final String message, final String uri, final int lineN
9999
*/
100100
public CSSParseException(final String message, final String uri,
101101
final int lineNumber, final int columnNumber, final Exception e) {
102-
super(ErrorCode.SYNTAX_ERR, message, e);
102+
super(message, e);
103103
uri_ = uri;
104104
lineNumber_ = lineNumber;
105105
columnNumber_ = columnNumber;

0 commit comments

Comments
 (0)