Support the ongoing development of Laravel.io →
posted 5 years ago
Laravel

Below is the log getting printed when an exception occurs in application:

"message" => "Unhandled critical exception occured", "context" => [ "class" => "Flight\Exception\FlightBookingErrorException", "code" => "GATEWAY_ERROR_UNKNOWN_ERROR", "message" => "Booking processing failed due to error at bank or wallet gateway\nGateway Error Code=> \nGateway Error Desc: ", "data" => [], "stack" => [ "#0 /app/app/Http/Controllers/PaymentController.php(25): Flight\Models\Booking\Service" . "->generateTicket('Amul Baby', '99999999999', 9846372618163345, AmericanExpressB)", "#1 [internal function]: Flight\Http\Controllers\PaymentController->processTicket()", "#2 /app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)", ] ]

In the above code, generateTicket method has four arguments and all the sensitive data(Name, Contact, AccountNumber, Bank Name) is logged.

Is there a way to stop logging of function arguments as part of stack trace?

Last updated 3 years ago.
0

Maybe you can use custom laravel exception handler app/Exception/Handler.php.

Something like this:

    public function report(Throwable $exception)
    {
        if ($exception instanceof \Flight\Exception\FlightBookingErrorException) {
            // custom code
        }

        parent::report($exception);
    }

https://laravel.com/docs/7.x/errors#report-method

#cmiiw

0

Thanks for the reply. I want more of a generic approach because there could be many methods which can have sensitive data as function arguments.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

RF sunilrazorpay Joined 3 Apr 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.