1 /*
2 * Copyright (c) Patrick Magauran 2018.
3 * Licensed under the AGPLv3. All conditions of said license apply.
4 * This file is part of ABOS.
5 *
6 * ABOS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ABOS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with ABOS. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package Utilities;
21 import java.sql.SQLException;
22
23 /**
24 * Created by patrick on 1/29/17.
25 */
26 public class CommonErrors {
27 /**
28 * @param e SQLexception to parse
29 * @return A plain-text error message for the exception
30 */
31 public static String returnSqlMessage(SQLException e) {
32 String retMsg;
33 switch (e.getSQLState()) {
34 case "S0022":
35 retMsg = "Database incompatible";
36 break;
37 default:
38 retMsg = "Error utilizing databse. Please try restarting the software.";
39 break;
40
41 }
42 return retMsg;
43 }
44 }