469
Views
2
Comments
Solved
How to handle Exceptions in Service Actions
Question
Application Type
Reactive

Hi community,

in my (ODC) setup I'm using one common backend app and three different frontend apps. The database and all the server actions are mainly handled within the backend app and the frontend apps are calling those via Service Actions.

My question is how to handle Exceptions triggered within the backend app? Currently the Exception is triggered within the backend app (where the logic happens). There I also have an Global Exception Handler for User Exceptions that triggers an alert informing about the Exception message (e.g. "Invalid deletion"). This does obviously not work when calling the function via a Service Action. Instead I receive a status code 500 from the called Service Action.

My best guess currently is:

  1. Put an Exception Handler into all of my Service Actions and output the error and error message to the frontend app calling the Service Action
  2. Checking for and triggering of an Exception within each frontend app function that makes a Service Call 
  3. Setting up another Exception Handler within the frontend app to handle these outputs (alert informing about the Exception message)

Is there a better way? This approach seems so repetitive and inefficient...


Thank you for your advice,

Konsti

2022-04-19 10-22-17
MFR
Solution

Hi Konsti,


There are many ways to do that but there are two main points where the majority of us will agree:

  • Front-end deal end-user input errors only
  • Back-end deal with coding errors (Exceptions, services unavailable, etc) only

The question then is, when we have a back-end error what should the front-end do? There is nothing that the user can do, so the main goal is to give a message to the user so that he doesn't feel lost and can restart the app/flow/screen. This message shouldn't be the exception message because 1) security reasons 2) the user won't understand it. A way to see it is, the person that needs to be informed of a system error is not the end-user but the maintenance team.


See this talk on minute 7:20 https://www.outsystems.com/nextstep/on-demand/technical-overviews/?wchannelid=1jzl2oi1en&wmediaid=e5ih041r7j


So a really simple answer on this is option 3 but with a generic error (Sorry , an unexpected system error occurred, please click below to restart).


2022-08-28 11-48-33
Konsti

Hi MFR,

good to know & makes sense! Thank you for the clarification and the reference.

Best

Konsti

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.