Giter Site home page Giter Site logo

Comments (2)

vimalloc avatar vimalloc commented on August 30, 2024

I looked at the source code of this extended and found that set_error_handler_callbacks processed these errors using the hook @app.errorhandler In init app function. however, these errors cannot be caught by flask.

They absolutely can! If flask isn't catching these errors for you, you are probably using another extension that breaks the native flask error handler functionality (flask-restful and flask-restplus have historically been problematic in this regard). Unfortunately if another extension breaks behavior that is part of the core flask api there isn't really anything I can do about it in my extension. It will need to be fixed by whatever extension is causing the issues. However, you can see some potential workarounds in #86 that might help!

from flask-jwt-extended.

yuqiuwen avatar yuqiuwen commented on August 30, 2024

I looked at the source code of this extended and found that set_error_handler_callbacks processed these errors using the hook @app.errorhandler In init app function. however, these errors cannot be caught by flask.

They absolutely can! If flask isn't catching these errors for you, you are probably using another extension that breaks the native flask error handler functionality (flask-restful and flask-restplus have historically been problematic in this regard). Unfortunately if another extension breaks behavior that is part of the core flask api there isn't really anything I can do about it in my extension. It will need to be fixed by whatever extension is causing the issues. However, you can see some potential workarounds in #86 that might help!

Ok, I guess its not related to flask-jwt-extended. its also can not be handled by flask when i used pyjwt, which raise DecodeError, and return 422 http status code. Confusingly, i handle DecodeError manually, still useless

@app.errorhandler(ExpiredSignatureError)
def handle_expire_sign_error(error):
    app.logger.error(error)
    return make_response('sign expired', code=Unauthorized.code)

@app.errorhandler(DecodeError)
def handle_decode_error(error):
    app.logger.error(error)
    return make_response('decode error', code=Unauthorized.code)

from flask-jwt-extended.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.