-
- Downloads
[IMP] Cleanup and refactoring of exception handling
Unify and refactor exception handling in framework and addons. The generic `except_osv` is now deprecated, and replaced by more specialized exception subtypes: - `UserError` (renamed from Warning, as it conflicts with the built-in `Warning`) raised when a non-technical error occurs during a business operation. It could be a missing information in the data provided by the user, or a misconfiguration. - `AccessError`: raised when any operation is denied because the user conducting it does not have the required access rights. - `AccessDenied`: raised when an operation that requires authenticated access is attempted via an unauthenticated request. - `MissingError`: raised when an operation is attempted on a record that does not exist. - `ValidationError`: raised when an operation violates a SQL or Python constraint. - All other exceptions are internal errors due to a system problem or bug, and raised untouched to the client-side, which should display a traceback. All exceptions take a single message argument. The `test_exceptions` module has been updated to showcase both new and old (deprecated) exceptions. A great many old `except_osv` had a useless title with "Error!" or "Warning", those have been removed, as this is handled by the client-side widget that displays the messages. This commit introduces a more consistent policy for logging errors and warnings: - All messages that do not require administrator attention should be logged at INFO level or lower. This includes all errors that are notified to the user in a friendly manner, even for access right problems or validation errors during business operations. - All messages that indicate a likely misconfiguration or malicious use by the users should be logged at WARNING level, as they typically require administrator attention. - All other unhandled internal errors cannot typically be handled by the user and should be logged at ERROR or higher level, as they require immediate administrator attention.
Showing
- addons/account/account.py 36 additions, 45 deletionsaddons/account/account.py
- addons/account/account_analytic_line.py 3 additions, 2 deletionsaddons/account/account_analytic_line.py
- addons/account/account_bank_statement.py 12 additions, 18 deletionsaddons/account/account_bank_statement.py
- addons/account/account_cash_statement.py 4 additions, 3 deletionsaddons/account/account_cash_statement.py
- addons/account/account_invoice.py 17 additions, 24 deletionsaddons/account/account_invoice.py
- addons/account/account_move_line.py 25 additions, 28 deletionsaddons/account/account_move_line.py
- addons/account/installer.py 2 additions, 1 deletionaddons/account/installer.py
- addons/account/product.py 3 additions, 1 deletionaddons/account/product.py
- addons/account/wizard/account_automatic_reconcile.py 2 additions, 1 deletionaddons/account/wizard/account_automatic_reconcile.py
- addons/account/wizard/account_change_currency.py 5 additions, 4 deletionsaddons/account/wizard/account_change_currency.py
- addons/account/wizard/account_financial_report.py 2 additions, 1 deletionaddons/account/wizard/account_financial_report.py
- addons/account/wizard/account_fiscalyear_close.py 5 additions, 6 deletionsaddons/account/wizard/account_fiscalyear_close.py
- addons/account/wizard/account_fiscalyear_close_state.py 2 additions, 1 deletionaddons/account/wizard/account_fiscalyear_close_state.py
- addons/account/wizard/account_invoice_refund.py 4 additions, 4 deletionsaddons/account/wizard/account_invoice_refund.py
- addons/account/wizard/account_invoice_state.py 3 additions, 2 deletionsaddons/account/wizard/account_invoice_state.py
- addons/account/wizard/account_move_bank_reconcile.py 2 additions, 2 deletionsaddons/account/wizard/account_move_bank_reconcile.py
- addons/account/wizard/account_open_closed_fiscalyear.py 2 additions, 1 deletionaddons/account/wizard/account_open_closed_fiscalyear.py
- addons/account/wizard/account_period_close.py 2 additions, 1 deletionaddons/account/wizard/account_period_close.py
- addons/account/wizard/account_report_aged_partner_balance.py 3 additions, 2 deletionsaddons/account/wizard/account_report_aged_partner_balance.py
- addons/account/wizard/account_report_common.py 2 additions, 1 deletionaddons/account/wizard/account_report_common.py
Loading
Please register or sign in to comment