@@ -123,19 +123,18 @@ public function handle(Request $request): Response
123
123
} catch (\Throwable $ e ) {
124
124
if ($ e instanceof \PDOException) {
125
125
if (strpos (strtolower ($ e ->getMessage ()), 'duplicate ' ) !== false ) {
126
- return $ this ->responder ->error (ErrorCode::DUPLICATE_KEY_EXCEPTION , '' );
127
- }
128
- if (strpos (strtolower ($ e ->getMessage ()), 'default value ' ) !== false ) {
129
- return $ this ->responder ->error (ErrorCode::DATA_INTEGRITY_VIOLATION , '' );
130
- }
131
- if (strpos (strtolower ($ e ->getMessage ()), 'allow nulls ' ) !== false ) {
132
- return $ this ->responder ->error (ErrorCode::DATA_INTEGRITY_VIOLATION , '' );
133
- }
134
- if (strpos (strtolower ($ e ->getMessage ()), 'constraint ' ) !== false ) {
135
- return $ this ->responder ->error (ErrorCode::DATA_INTEGRITY_VIOLATION , '' );
126
+ $ response = $ this ->responder ->error (ErrorCode::DUPLICATE_KEY_EXCEPTION , '' );
127
+ } elseif (strpos (strtolower ($ e ->getMessage ()), 'default value ' ) !== false ) {
128
+ $ response = $ this ->responder ->error (ErrorCode::DATA_INTEGRITY_VIOLATION , '' );
129
+ } elseif (strpos (strtolower ($ e ->getMessage ()), 'allow nulls ' ) !== false ) {
130
+ $ response = $ this ->responder ->error (ErrorCode::DATA_INTEGRITY_VIOLATION , '' );
131
+ } elseif (strpos (strtolower ($ e ->getMessage ()), 'constraint ' ) !== false ) {
132
+ $ response = $ this ->responder ->error (ErrorCode::DATA_INTEGRITY_VIOLATION , '' );
136
133
}
137
134
}
138
- $ response = $ this ->responder ->error (ErrorCode::ERROR_NOT_FOUND , $ e ->getMessage ());
135
+ if (!$ response ) {
136
+ $ response = $ this ->responder ->error (ErrorCode::ERROR_NOT_FOUND , $ e ->getMessage ());
137
+ }
139
138
if ($ this ->debug ) {
140
139
$ response ->addHeader ('X-Exception-Message ' , $ e ->getMessage ());
141
140
$ response ->addHeader ('X-Exception-File ' , $ e ->getFile () . ': ' . $ e ->getLine ());
0 commit comments