Task List custom Error Notification

Hi, We have created a custom REST API and used in tasklist. The issue is when an error occurs it is throwing the technical alert on the screen instead of the custom error that we pass. How can i change this behaviour?