Updated error response to look a requested format to determine wether to return json or not.