ONYX
ONYX

Reputation: 5859

error code for delete operation response

What is the error code for a delete operation that doesn't return true e.g.

if($post->delete()) {
     return response()->json(['message' => 'successfully deleted'], 200);
} else {
    return response()->json(['message' => 'something went wrong', error_code_here);
}

Upvotes: 0

Views: 147

Answers (1)

Vishal Varshney
Vishal Varshney

Reputation: 905

When the error handling code is not there, Laravel returns an HTTP 500 error, regardless of the specific error thrown in the code.

E.g. abort(403) would return a 500 error.

Upvotes: 2

Related Questions