Skip to content

Error handler call order is not deterministic #202

@avilaton

Description

@avilaton

Code

Here is sample code where the issue is seen

class GenericError(Exception):
    pass


class SomeSpecificError(GenericError):
    pass


ns = Namespace("some_route")

@ns.errorhandler(SomeSpecificError)
def handle_specific_error(error):
    return {"message": "something specific happened"}, 401

@ns.errorhandler(GenericError)
def handle_generic_error(error):
    return {"message": "generic error"}, 401

Repro Steps (if applicable)

  1. raise SomeSpecificError from any route handler
  2. run this test repeatedly
  3. Broken!

Expected Behavior

the order in which the error handlers are registered should be taken into account when those are looked up for a given exception

Actual Behavior

Handlers are called in non deterministic order

Environment

  • Python version 3.5
  • Flask version 1.0.3
  • Flask-RESTX version 0.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions