-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionUtil.java
More file actions
24 lines (20 loc) · 821 Bytes
/
ExceptionUtil.java
File metadata and controls
24 lines (20 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package webapp.sql;
import org.postgresql.util.PSQLException;
import webapp.exceptions.StorageException;
import java.sql.SQLException;
public class ExceptionUtil {
private ExceptionUtil() {
}
public static StorageException convertException(SQLException e) {
if (e instanceof PSQLException) {
System.out.println("SQLException message: " + e.getMessage());
System.out.println("SQLException SQL state: " + e.getSQLState());
System.out.println("SQLException SQL error code: " + e.getErrorCode());
// http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html
if (e.getSQLState().equals("23505")) {
return new StorageException("UUID is not found");
}
}
return new StorageException(e);
}
}