1. Go to this page and download the library: Download ptdot/errormessage library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// default usage using facade
try {
throw new \Exception('This is exception message');
} catch (\Exception $exception) {
return response()->json([
'errors' => ErrorMessage::displayExceptionMessage($exception)
], 500);
}
// you may need traceAsString option enabled using this way:
return response()->json([
'errors' => ErrorMessage::traceAsString()->displayExceptionMessage($exception)
], 500);
// Need to override exception message? Don't worry
return response()->json([
'errors' => ErrorMessage::displayExceptionMessage($exception, 'exception message will be overrided with this')
], 500);
bash
php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.