Giter VIP home page Giter VIP logo

Comments (6)

nWidart avatar nWidart commented on May 27, 2024 1

Ah nice, that's nicer! Thanks! 😄

from sentry-laravel.

nWidart avatar nWidart commented on May 27, 2024

Actually, it was fairly easy to implement using the following code:

if (in_array(get_class($e), $this->dontReport, true)) {
    parent::report($e);
    return;
}

For for the trouble :)

from sentry-laravel.

stayallive avatar stayallive commented on May 27, 2024

You have to do this yourself, this is also done in the example applications.

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception $exception
     *
     * @return void
     */
    public function report(Exception $exception)
    {
        if ($this->shouldReport($exception)) {
            app('sentry')->captureException($exception);
        }

        parent::report($exception);
    }

from sentry-laravel.

cviebrock avatar cviebrock commented on May 27, 2024

Is there a nice way to do the same thing in Laravel 4.x? Right now, I just have the following in app/start/global.php:

App::error(function (Exception $exception, $code) {

    // Add some extra context to Sentry
    app('sentry')->user_context(array(
        'ip_address' => Request::ip()
    ));

    Log::error($exception);
});

from sentry-laravel.

stayallive avatar stayallive commented on May 27, 2024

@cviebrock in L5 it's just an array of exception with a helper method so you could do this:

You should check if that are the correct classes and namespaces and add some more maybe :) I cannot remember which there all are in L4.

/**
 * Determine if the exception is in the "do not report" list.
 *
 * @param  \Exception  $e
 * @return bool
 */
function shouldntReportException(Exception $e)
{
    $dontReport = array(
        'Illuminate\Http\Exception\HttpResponseException',
        'Illuminate\Database\Eloquent\ModelNotFoundException',
        'Symfony\Component\HttpKernel\Exception\HttpException',
        'Symfony\Component\HttpKernel\Exception\NotFoundHttpException',
    );

    foreach ($dontReport as $type) {
        if ($e instanceof $type) {
            return true;
        }
    }

    return false;
}

App::error(function (Exception $exception, $code) {
    // Ignore all errors we don't care about
    if (shouldntReportException($exception)) {
        return;
    }

    // Add some extra context to Sentry
    app('sentry')->user_context(array(
        'ip_address' => Request::ip()
    ));

    Log::error($exception);
});

from sentry-laravel.

cviebrock avatar cviebrock commented on May 27, 2024

That's what I figured I'd need to do (i.e. implement it myself). Thanks!

from sentry-laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.