Skip to content

Conversation

@andriacap
Copy link

@andriacap andriacap commented Apr 23, 2025

  • Create decorator to handle Integrity Error or other error on process CRUD
  • Add decorator on delete route for organisms and users

Before when error happened

image

After with handle error

image

image

Reviewed-by: andriacap

- Add decorator to handle Integrity Error or other error on process CRUD
- Add decorator on delete route for organisms and users

Reviewed-by: andriac
@andriacap andriacap force-pushed the fix/handling-error-route-backend branch from d321c48 to 290d671 Compare April 23, 2025 13:27
Copy link
Contributor

@jacquesfize jacquesfize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L'idée est bonne ! Toutefois, je pense que la déclaration du décorateurs sur les routes concernées n'est pas idéal. Je pense qu'il est plus simple de s'appuyer sur la mécanique Flask des error_handlers https://flask.palletsprojects.com/en/stable/errorhandling/.

L'idée serait d'appeller une fonction à chaque erreur 500. Dans cette fonction, si l'erreur est une erreur SQLA, on affiche le message d'erreur (dans un flash).

6,
)
@fnauth.check_auth(6)
@handle_db_errors("user.users", "l'utilisateur", redirect_on_error=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lourd si on doit déclarer ça plusieurs fois ...

Copy link
Author

@andriacap andriacap Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai proposé une solution centralisée en terme de gestion d'erreurs

@andriacap andriacap force-pushed the fix/handling-error-route-backend branch from ab37e68 to fc80d3e Compare July 17, 2025 09:20
- Add handler function according to current function existing in errors.py

Reviewed-by: andriac
@andriacap andriacap force-pushed the fix/handling-error-route-backend branch from fc80d3e to b36db95 Compare July 17, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants