Search code examples
javascriptformslaravel-5abortsweetalert

How to abort 500 in production?


I have a feedback form and want to test .fail message (use sweetalert swal method). How artificially to trigger a 500 error when sending form in production environment (in local it`s work)? Thanks for any help)


Solution

  • A 500 error signals a fatal error during execution. To trigger that explicitly, simply make your app fail so it returns a non-0 status code. Throwing an exception will do, but the most straight-forward way is to simply exit with a non-0 status code:

    exit 1;
    

    You could also configure your web server to return the HTTP status code directly for specific URLs/requests; for example an .htaccess configuration:

    RewriteCond %{REQUEST_METHOD} POST
    RewriteRule /my/submit/uri - [R=500]