TrustPeer Error Macros: #include "errprog.h"

This page describes the macros that can be used to assert normal and programming errors

1. programming Errors (assertions):

You should only use the following macros when you try to find failed pre/invariant/post conditions. They will log that an unpredicted error happened and where it happened.

E(expr)  if expr is not null then ends the function and forces it to return ERRPROG

EN(expr)  if expr==ERRPROG then ends the function and forces it to return ERRPROG
Most of the times EN should be followed by a Normal error test, hence its name !!!

END ends the function and forces it to return ERRPROG

2. Normal non null error values (as defined in a contract). Nothing will be logged:

N(expr)  if expr is not null then ends the function and forces it to return ERRNORM (#define ERRNORM 2)

NV(expr,val)  if expr is not null then ends the function and forces it to return val

NEND ends the function and forces it to return ERRNORM

3. Super macros that combine Programming and Normal errors (you should find these are the most convenient)

S(expr)  does EN(expr) then N(expr)

SV(expr,val)  does EN(expr) then NV(expr,val)

Click here for some simple examples