How to abort with custom message in Laravel

If you want to abort with a custom message, you will find that in some code like this,

abort(400, 'custom error message');

the above code will show you the standard 400 error without any custom messages. You need to write the code like this

abort(
    response()->json(['message' => "My Custom error message"], 400)
  );

Leave a Reply

Your email address will not be published. Required fields are marked *