Made return format to return error when code is not 2xx