[Gameplay Ability System] Changing Cost if Cost is not available


I am using GAS with 2 attributes HEALTH and ENERGY. A “Gameplay Ability” GA_MELEE is defined which costs some ENERGY.

I want to change the cost of an ability if the character does not have enough ENERGY, then the difference of cost should be deducted from HEALTH and the ability should execute.
E.g. the player has 10 ENERGY but the GA_MELEE costs 20 ENERGY, so the ability wont execute. How to make it so that the cost is deducted from ENERGY but if it is insufficient then 10 points are deducted from HEALTH attribute?

I just need reference to some built in functions to modify cost before it is checked