How to ignore flasks http 400 exception in Sentry












0















I have setup a flask project in Sentry but have noticed a problem that I need to fix.



Currently if the flask application throws a HTTPException (for example for a validation exception) that exception creates an issue in Sentry. This clutters up the issues since it creates issues even for HTTP 400.



Are there any way to configure Sentry so it ignores all HTTPExceptions with code 4xx but still create Issues for all HTTPExceptions with code 5xx?










share|improve this question























  • Hi, could you post a small example and tell us which SDK you are using? This sounds like a bug

    – Markus Unterwaditzer
    Nov 14 '18 at 23:59
















0















I have setup a flask project in Sentry but have noticed a problem that I need to fix.



Currently if the flask application throws a HTTPException (for example for a validation exception) that exception creates an issue in Sentry. This clutters up the issues since it creates issues even for HTTP 400.



Are there any way to configure Sentry so it ignores all HTTPExceptions with code 4xx but still create Issues for all HTTPExceptions with code 5xx?










share|improve this question























  • Hi, could you post a small example and tell us which SDK you are using? This sounds like a bug

    – Markus Unterwaditzer
    Nov 14 '18 at 23:59














0












0








0








I have setup a flask project in Sentry but have noticed a problem that I need to fix.



Currently if the flask application throws a HTTPException (for example for a validation exception) that exception creates an issue in Sentry. This clutters up the issues since it creates issues even for HTTP 400.



Are there any way to configure Sentry so it ignores all HTTPExceptions with code 4xx but still create Issues for all HTTPExceptions with code 5xx?










share|improve this question














I have setup a flask project in Sentry but have noticed a problem that I need to fix.



Currently if the flask application throws a HTTPException (for example for a validation exception) that exception creates an issue in Sentry. This clutters up the issues since it creates issues even for HTTP 400.



Are there any way to configure Sentry so it ignores all HTTPExceptions with code 4xx but still create Issues for all HTTPExceptions with code 5xx?







flask sentry






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 12:13









Magnus LundbergMagnus Lundberg

4715




4715













  • Hi, could you post a small example and tell us which SDK you are using? This sounds like a bug

    – Markus Unterwaditzer
    Nov 14 '18 at 23:59



















  • Hi, could you post a small example and tell us which SDK you are using? This sounds like a bug

    – Markus Unterwaditzer
    Nov 14 '18 at 23:59

















Hi, could you post a small example and tell us which SDK you are using? This sounds like a bug

– Markus Unterwaditzer
Nov 14 '18 at 23:59





Hi, could you post a small example and tell us which SDK you are using? This sounds like a bug

– Markus Unterwaditzer
Nov 14 '18 at 23:59












1 Answer
1






active

oldest

votes


















0














If I’m not mistaken, Sentry should only send not handled exceptions. So you could setup custom error handlers: http://flask.pocoo.org/docs/1.0/patterns/errorpages/?highlight=error%20handler#error-handlers



If you want to handle all default exceptions you could register an error handler like this:



 from werkzeug.exceptions import default_exceptions

def register_error_handlers(app):
""" Register error handler for default exceptions """

for code in default_exceptions:
app.register_error_handler(code, your_error_handler)


where app is your flask App instance and your_error_handler takes the error as argument and returns a response. So you could filter for the 400 codes in this for loop to only handle 4xx errors.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299982%2fhow-to-ignore-flasks-http-400-exception-in-sentry%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If I’m not mistaken, Sentry should only send not handled exceptions. So you could setup custom error handlers: http://flask.pocoo.org/docs/1.0/patterns/errorpages/?highlight=error%20handler#error-handlers



    If you want to handle all default exceptions you could register an error handler like this:



     from werkzeug.exceptions import default_exceptions

    def register_error_handlers(app):
    """ Register error handler for default exceptions """

    for code in default_exceptions:
    app.register_error_handler(code, your_error_handler)


    where app is your flask App instance and your_error_handler takes the error as argument and returns a response. So you could filter for the 400 codes in this for loop to only handle 4xx errors.






    share|improve this answer






























      0














      If I’m not mistaken, Sentry should only send not handled exceptions. So you could setup custom error handlers: http://flask.pocoo.org/docs/1.0/patterns/errorpages/?highlight=error%20handler#error-handlers



      If you want to handle all default exceptions you could register an error handler like this:



       from werkzeug.exceptions import default_exceptions

      def register_error_handlers(app):
      """ Register error handler for default exceptions """

      for code in default_exceptions:
      app.register_error_handler(code, your_error_handler)


      where app is your flask App instance and your_error_handler takes the error as argument and returns a response. So you could filter for the 400 codes in this for loop to only handle 4xx errors.






      share|improve this answer




























        0












        0








        0







        If I’m not mistaken, Sentry should only send not handled exceptions. So you could setup custom error handlers: http://flask.pocoo.org/docs/1.0/patterns/errorpages/?highlight=error%20handler#error-handlers



        If you want to handle all default exceptions you could register an error handler like this:



         from werkzeug.exceptions import default_exceptions

        def register_error_handlers(app):
        """ Register error handler for default exceptions """

        for code in default_exceptions:
        app.register_error_handler(code, your_error_handler)


        where app is your flask App instance and your_error_handler takes the error as argument and returns a response. So you could filter for the 400 codes in this for loop to only handle 4xx errors.






        share|improve this answer















        If I’m not mistaken, Sentry should only send not handled exceptions. So you could setup custom error handlers: http://flask.pocoo.org/docs/1.0/patterns/errorpages/?highlight=error%20handler#error-handlers



        If you want to handle all default exceptions you could register an error handler like this:



         from werkzeug.exceptions import default_exceptions

        def register_error_handlers(app):
        """ Register error handler for default exceptions """

        for code in default_exceptions:
        app.register_error_handler(code, your_error_handler)


        where app is your flask App instance and your_error_handler takes the error as argument and returns a response. So you could filter for the 400 codes in this for loop to only handle 4xx errors.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 14 '18 at 16:55

























        answered Nov 14 '18 at 16:47









        Paul GötzePaul Götze

        287320




        287320
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299982%2fhow-to-ignore-flasks-http-400-exception-in-sentry%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma