Skip to content

Make error handlers order of registration respected when handling errors #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flask_restx/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def __init__(
self._default_error_handler = None
self.tags = tags or []

self.error_handlers = {
self.error_handlers = OrderedDict({
ParseError: mask_parse_error_handler,
MaskError: mask_error_handler,
}
})
self._schema = None
self.models = {}
self._refresolver = None
Expand Down Expand Up @@ -559,7 +559,7 @@ def __schema__(self):

@property
def _own_and_child_error_handlers(self):
rv = {}
rv = OrderedDict()
rv.update(self.error_handlers)
for ns in self.namespaces:
for exception, handler in six.iteritems(ns.error_handlers):
Expand Down
4 changes: 2 additions & 2 deletions flask_restx/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import inspect
import warnings
import logging
from collections import namedtuple
from collections import namedtuple, OrderedDict

import six
from flask import request
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(
self.urls = {}
self.decorators = decorators if decorators else []
self.resources = [] # List[ResourceRoute]
self.error_handlers = {}
self.error_handlers = OrderedDict()
self.default_error_handler = None
self.authorizations = authorizations
self.ordered = ordered
Expand Down