How to get raw Exception Message in Laravel?

March 15, 2020

If you want to get raw exception message without HTML code in Laravel you can use the following method

$e->getMessage()

This is the sample code for it

try{

// some code here


} catch (\Exception $e) {

  return response()->json(['type' => 'warn', 'title' => "Unable to Create Contact", "message" => $e->getMessage()]);
}