I was relying on variable_DIALSTATUS to check for the originate error cause when dialing a user, it works for error cases like RECOVERY_ON_TIMER_EXPIRE, BUSY, however when the cause is USER_NOT_REGISTERED freeswitch overrides the DIALSTATUS with the pickup endpoint's error cause so I'm unable to detect the reason properly.
How can I reliably retrieve the originate cause? Is this a bug or intended?
016-09-01 23:17:35.561182 [NOTICE] switch_ivr_originate.c:2759 Cannot create outgoing channel of type [error] cause: [USER_NOT_REGISTERED]
2016-09-01 23:17:35.561182 [DEBUG] mod_dptools.c:3709 () State Change CS_NEW -> CS_ROUTING
2016-09-01 23:17:35.561182 [DEBUG] switch_core_session.c:1397 Send signal N/A [BREAK]
2016-09-01 23:17:35.561182 [NOTICE] switch_channel.c:1077 New Channel pickup/221@example.com [446024c6-709a-11e6-a2c0-4d1647ad42e6]