// Exec runs the use case. func (kase *CreateWebhook) Exec(hook entity.Webhook) (uid RepoID, err error) { hook.ID = &RepoID{} err = hook.Valid() if err != nil { err = &CreateWebhookError{Step: "validate", Child: err} return } err = kase.DB.SaveWebhook(&hook) if err != nil { err = &CreateWebhookError{Step: "repo", Child: err} return } if hook.IsNew() { // TODO: add some further explanation that the repo failed to assign // and ID. err = &CreateWebhookError{Step: "repo"} return } uid = *hook.ID.(*RepoID) return }