Fail a canister upgrade

Hi everyone,
Is there a way to fail and stop a canister installation if the preupgrade or postupgrade fails ?
I encountered an issue while upgrading my canister after adding an Int field to one of my types. The object was not kept.
I guess the solution is to only add Optional fields so the upgrading process run smoothly but I still want to figure out a way to stop the upgrade process if anything goes wrong.
Do you have any idea ?