Skip to content

Commit

Permalink
fix: don't log stacktrace for common exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tadams42 committed Jul 26, 2023
1 parent 78189e2 commit 88c1b8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ jobs:
# Tests coverage
#---------------------------------------------------------------------------------
# We need coverage data only from single tests run.
- name: "run tests with coverage"
- name: "run tests with coverage 🔹 🐍 3.11"
if: ${{ matrix.python-version == '3.11' && matrix.data-layer == 'SQLAlchemy 2.x' && matrix.db-api == 'psycopg 3'}}
run: coverage run -m pytest

- name: "coverage report"
- name: "coverage report 🔹 🐍 3.11"
if: ${{ matrix.python-version == '3.11' && matrix.data-layer == 'SQLAlchemy 2.x' && matrix.db-api == 'psycopg 3'}}
run: coverage report

- name: "generate coverage xml"
- name: "generate coverage xml 🔹 🐍 3.11"
if: ${{ matrix.python-version == '3.11' && matrix.data-layer == 'SQLAlchemy 2.x' && matrix.db-api == 'psycopg 3'}}
run: coverage xml -i

- name: "generate coverage report"
- name: "generate coverage report 🔹 🐍 3.11"
if: ${{ matrix.python-version == '3.11' && matrix.data-layer == 'SQLAlchemy 2.x' && matrix.db-api == 'psycopg 3'}}
run: coverage report

- name: "upload coverage to codecov.io"
- name: "upload coverage to codecov.io 🔹 🐍 3.11"
if: ${{ matrix.python-version == '3.11' && matrix.data-layer == 'SQLAlchemy 2.x' && matrix.db-api == 'psycopg 3'}}
uses: codecov/[email protected]
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import flask
from werkzeug.exceptions import default_exceptions
from marshmallow import ValidationError

from .error_formatters import error_response_from

Expand Down Expand Up @@ -56,15 +57,14 @@ def zero_division_handler(error):

@classmethod
def _std_handler(cls, error):
if error in {401, 403, 405} or isinstance(
error,
(default_exceptions[401], default_exceptions[403], default_exceptions[405]),
if isinstance(error, ValidationError):
logger.error(f"ValidationError: {error}", exc_info=False)
elif error == 405 or isinstance(error, default_exceptions[405]):
logger.error(f"{error} ", exc_info=False)
elif error in {401, 403} or isinstance(
error, (default_exceptions[401], default_exceptions[403])
):
logger.debug(
"Exception bubbled to top level handler and was returned as HTTP "
"JSON response.",
exc_info=True,
)
logger.error(f"Authentication {error}", exc_info=False)
else:
logger.error(
"Exception bubbled to top level handler and was returned as HTTP "
Expand Down

0 comments on commit 88c1b8c

Please sign in to comment.