How to return a success value from middleware when server function fails

I know I had to return the result from next function but how to catch a error and return a success ?
Was this page helpful?