achieve the error handler code in frontend