@@ -134,27 +134,6 @@ protected void setAuthorizationProblem(@NotNull HttpServletResponse resp){
134
134
resp .addHeader ("ErrorMessage" , "Are you sure you logged in?" );
135
135
}
136
136
137
- private void handleSQLException (@ NotNull SQLException e , HttpServletResponse resp ){
138
- String sqlState = e .getSQLState ();
139
- if (sqlState == null ) sqlState = "" ;
140
- switch (sqlState ){
141
- case "23515" :
142
- resp .setStatus (403 );
143
- resp .addHeader ("ErrorMessage" , "You have no permissions for this action." );
144
- break ;
145
- case "23516" :
146
- case "45000" :
147
- case "23505" :
148
- resp .setStatus (409 );
149
- resp .addHeader ("ErrorMessage" , "You are trying to create duplicate entity." );
150
- break ;
151
- default :
152
- resp .setStatus (500 );
153
- resp .addHeader ("ErrorMessage" , e .getMessage ());
154
- break ;
155
- }
156
- }
157
-
158
137
protected void setErrorHeader (@ NotNull HttpServletResponse resp , String errorMessage ){
159
138
resp .addHeader ("ErrorMessage" , errorMessage );
160
139
}
@@ -207,23 +186,15 @@ protected void handleException(HttpServletResponse resp, @NotNull Exception e){
207
186
case "AuthenticationException" :
208
187
setAuthorizationProblem (resp ,e );
209
188
return ;
210
- case "SQLException" :
211
- case "SQLIntegrityConstraintViolationException" :
212
- handleSQLException ((SQLException ) e , resp );
213
- return ;
214
189
case "AqualityPermissionsException" :
215
- resp .setStatus (403 );
216
- resp .addHeader ("ErrorMessage" , e .getMessage ());
217
- return ;
218
190
case "AqualityException" :
219
- resp .setStatus (500 );
220
- resp .addHeader ("ErrorMessage" , e .getMessage ());
221
- return ;
222
191
case "InvalidFormatException" :
223
192
case "AqualityQueryParameterException" :
224
- resp .setStatus (422 );
225
- resp .addHeader ("ErrorMessage" , e .getMessage ());
226
-
193
+ case "AqualitySQLException" :
194
+ AqualityException exception = (AqualityException ) e ;
195
+ resp .setStatus (exception .getResponseCode ());
196
+ resp .addHeader ("ErrorMessage" , exception .getMessage ());
197
+ return ;
227
198
default :
228
199
setUnknownIssue (resp );
229
200
}
0 commit comments