change to json error handler