func (this *RespondWith) Error(httpStatus int, err api.Error) { response := gin.H{ "error_code": httpStatus, } if err.Any() { if err.IsUserError() { response["message"] = err.Text() } else if gin.Mode() != gin.ReleaseMode { response["debug_message"] = err.Text() delete(response, "message") } } this.GinContext.JSON(httpStatus, response) }