Setting error code when inside error structure