flexmeasures.utils.error_utils
Utils for handling of errors
Functions
- flexmeasures.utils.error_utils.add_basic_error_handlers(app: Flask)
Register classes we care about with the generic handler. See also the auth package for auth-specific error handling (Unauthorized, Forbidden)
- flexmeasures.utils.error_utils.error_handling_router(error: HTTPException)
Generic handler for errors. We respond in json if the request content-type is JSON. The ui package can also define how it wants to render HTML errors, by setting a function.
- flexmeasures.utils.error_utils.get_err_source_info(original_traceback=None) dict
Use this when an error is handled to get info on where it occurred.
- flexmeasures.utils.error_utils.log_error(exc: Exception, error_msg: str)
Collect meta data about the exception and log it. error_msg comes in as an extra attribute because Exception implementations differ here.
- flexmeasures.utils.error_utils.print_query(query: Query) str
Print full SQLAlchemy query with compiled parameters.
Recommended use as developer tool only.
Adapted from https://stackoverflow.com/a/63900851/13775459