Handle errors and give reasonable response, for both API and UI
Handle errors and give reasonable response, for both API and UI