How to ignore flasks http 400 exception in Sentry
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
add a comment |
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
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
add a comment |
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
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
flask sentry
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
edited Nov 14 '18 at 16:55
answered Nov 14 '18 at 16:47
Paul GötzePaul Götze
287320
287320
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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