-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathSqlResourceException.java
More file actions
51 lines (43 loc) · 1.28 KB
/
SqlResourceException.java
File metadata and controls
51 lines (43 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Copyright (c) restSQL Project Contributors. Licensed under MIT. */
package org.restsql.core;
/**
* Represents a restSQL error, typically wrapping an <code>SQLException</code> and adding an SQL String. Calling
* <code>getMessage()</code> and <code>toString()</code> will include the SQL in the output. The class can also be used
* to wrap other exceptions. It is also the superclass for other restSQL errors allowing the framework to manage a
* single exception in method signatures.
*
* @author Mark Sawers
*/
public class SqlResourceException extends Exception {
private static final long serialVersionUID = 1L;
private String sql;
public SqlResourceException(String message) {
super(message);
}
public SqlResourceException(Throwable cause) {
super(cause);
}
public SqlResourceException(Throwable cause, String sql) {
super(cause);
this.sql = sql;
}
public SqlResourceException(String message, String sql) {
super(message);
this.sql = sql;
}
public String getSql() {
return sql;
}
public String getMessage() {
String message;
if (getCause() != null) {
message = getCause().getMessage();
} else {
message = super.getMessage();
}
if (sql != null) {
message += " :: " + sql;
}
return message;
}
}