How the enclave reason code is calculated

The enclave reason code provides additional information in support of the enclave return code. Language Environment calculates the enclave reason code by multiplying a severity code (that indicates how an enclave terminated) by 1000.

The severity code is initially set to 0, indicating normal enclave termination. If the Termination_Imminent due to STOP (T_I_S) condition is signaled, it is set to 1. If the enclave terminates due to an unhandled condition of severity 2 or greater, the enclave reason code is set according to the severity of the unhandled condition that caused the enclave to terminate, as shown in Table 1. For more information about Language Environment conditions and severity codes, see Table 1.

Table 1 contains a summary of the enclave reason code produced when an enclave terminates. The condition severity column indicates the reason code for the original condition.
Table 1. Summary of enclave reason codes
Condition severity Meaning Enclave reason code (R0)
0 Normal application termination 0
Severity 1 condition Termination_Imminent due to STOP 1000
Unhandled severity 2 condition Error — abnormal termination 2000
Unhandled severity 3 condition Severe error — abnormal termination 3000
Unhandled severity 4 condition Critical error — abnormal termination 4000