10
Views
3
Comments
Solved
How to use exception handler in OnSyncError client action (OfflineDataSync pattern)
Application Type
Mobile

Hi,

I want to raise a specific exception in the OfflineDataSync client action that will run in the background and handle it in the OnSyncError action on the screen where it was called. I am checking whether the user is still logged in when the OfflineDataSync is started, and if they are not it must redirect them to the login page. 

The problem is that only an Error Message and Sync Unit is passed to the OnSyncError client action and the only way I could identify the specific error would be to pass a code/identifier through the error message text when raising the exception (which doesn't seem very scalable/maintainable and possibly error prone, excuse the pun).

Could someone please advise if there is a better way around this? Or is that the only way I will be able to distinguish which error is being thrown in the OfflineDataSync?

Thanks in advance :)

Kind regards,

Heinri

Solution

Hi,

I see now there is an OnSync action in the OfflineDataSyncEvents web block:

In this action you can set exception handlers to handle the exceptions thrown in the offline data sync (and in my case navigate back to the login).

I just wanted to post this here for future reference, in case anyone else had a question like this.

Kind regards,

Heinri

Rank: #70

Hi Heinri,


You can always use GetUserId() to see if there is a user logged in. If it returns NullIdentifier(), there is no user logged-in, otherwise it will return you the logged-in User Identifier. Something like in the example below:


 

Hope it helps.


Kind Regards,
João

Solution

Hi,

I see now there is an OnSync action in the OfflineDataSyncEvents web block:

In this action you can set exception handlers to handle the exceptions thrown in the offline data sync (and in my case navigate back to the login).

I just wanted to post this here for future reference, in case anyone else had a question like this.

Kind regards,

Heinri