handle errors when mimetype is json