CI/CD how to capture status of the cancelled stage

Hi Team,

Suppose I am having GitLab pipeline, in which I am having 6 stages.
I have added each stage status in build.env in after_script tag.
I am accessing status of all the stages in .post stage to verify the final pipeline status, but same process will not work when any user cancelled any stage. As I am not getting any option to get the status of cancelled stage.

Can you please help me to get or capture the status of that cancelled stage?

Thanks in advance.