Why we need to implement error handling / designing beyond the happy path:
- What happens When don't implement fault handling logic of any kind. By default every error occurs runtime, deliver to the OIC error hospital which is part of the oic runtime environwmnt, hosting all your deployed integrations, this can include any faults like runtime or business faults, request timeouts, invalid payloads, internal error etc.
- When error hospital catches a fault, the integration flow stops or terminated immediately
- If you work on the projects, it will show on the observe page.
- If the integration is sync app driven and fault happens, the error hospital sends the same fault details to the client.
- All the errors are visible in the visibility secrion >> error page.
Instead of allowing the error hospital to catch every fault, we can intentionally catch all fault using the global and scope fault handlers.
Best practice Examples of error handling:
- Log the error but continue with the integration flow.
- Invoke a secondary service for backup processing.
- Log the error and then terminate the integration flow
- Invoke another service for notification or error handling processing.
- Reply to the integration glow's client with a custom error response.
- Send an email notification to an external stakeholder or an internal administrator.
- Invoke an OIC process to initiate a process workflow involving manual intervention.
Implementing Global Fault handler:
- By default, there is default global fault handler, where it has re-throw fault action which rethrows the fault to OIC error hospital.
- All uncaught faults and errors go to global fault handler
- Throw new fault from scope fault handler
- Re throw fault from scope fault.handler.
- Change the default handling logic apt for your integration like
- add logger,
- email notification.
- Map custom data for a fault return for sync integrations
- Mitigate the error contion with alt logic
- Invoke an error handling service(another oic integration or external service)
Global fault handlers End actions;
- Re throw fault : it will send the fault to error hospital,
- Throw new fault: it will send a custom fault details to error hospital
- Stop: Terminate the integration flow, no error hospital will be involved. Separate fault handling logic wii be there before the stop action.
- Fault return: explicitly sending the business faults to the client for sync service. No error hospital is involved.
- Return : fault mitigation logic, invoking a backup service, then send the normal.data to the client. No error hospital is involved.
For each invoke , try to create a scope and define scope fault handler.
Inner scope >> outer scope >> global >> error hospital
Note:
For my project, I have followed as below:
- For each invoke>> take it in one scope and in the default fault handle >> throw new fault with code, reason and details.
- In global fault handler >> we have send the the global failt details to data dog SaaS application for further support.
- We have created a lookup like common_error_details_lookup where it captures the key, error type, error code, reason and details. Using the key like 'UCMUPLOADFAILED' we can fetch custom error details.
No comments:
Post a Comment