Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to called except block to allow converting exceptions to arbitrary

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 316
    Comment on it

    To Called within an except block to allow converting exceptions to arbitrary responses. Anything returned (except None) will be used as response. use this code given below in openerp.

    1. def _handle_exception(self, exception):
    2. """Called within an except block to allow converting exceptions
    3. to arbitrary responses. Anything returned (except None) will
    4. be used as response."""
    5. try:
    6. return super(JsonRequest, self)._handle_exception(exception)
    7. except Exception:
    8. if not isinstance(exception, (openerp.exceptions.Warning, SessionExpiredException, openerp.exceptions.except_orm)):
    9. _logger.exception("Exception during JSON request handling.")
    10. error = {
    11. 'code': 200,
    12. 'message': "Odoo Server Error",
    13. 'data': serialize_exception(exception)
    14. }
    15. if isinstance(exception, AuthenticationError):
    16. error['code'] = 100
    17. error['message'] = "Odoo Session Invalid"
    18. if isinstance(exception, SessionExpiredException):
    19. error['code'] = 100
    20. error['message'] = "Odoo Session Expired"
    21. return self._json_response(error=error)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: