Reputation: 10095
I have below code
try {
$Role = $this->Get($obj->RoleID);
if($Role == null) {
return trans('Role.RoleNotFound');
}
$Role->Role = $obj->Role;
$Role->save();
} catch (Exception $ex) {
dd($ex);
return $ex;
}
I am passing below data to this function
{#157 ▼
+"Role": "wsedde"
+"RoleID": "31"
}
What's the problem?
As per the schema Role column has length = 2 and I by mistake passed length greater then 2. I have try catch applied but exception is not showing.
Can you tell why it does not go inside catch block?
Upvotes: 1
Views: 25
Reputation: 179994
Try catch (\Exception $ex)
(or alternatively, adding use Exception;
to the top of the file right under the namespace declaration, with the other use
statements). Laravel's namespacing likely means you're inadvertently attempting to catch (App\Http\Controllers\Exception $ex)
here.
Upvotes: 2