jeudi 25 avril 2019

How to delegate exception to global exception in Laravel?

There is typical code in controller Laravel:

public function create(CreateInvoiceRequest $request)
    {

        try {

            $invoice = Invoice::create(['']);

            return response()->json($model);

        } catch (\Exception $e) {
            return \Response::json(["errors" => $e->getMessage()], 400);
        }
    }

In exception case I catch it and show message, how to delagate (move) this in global exception Laravel? Need I do something like this?

try { } } catch (\Exception $e) { throw new Exception($e); }



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2ZzQlnN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire