diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-10-22 09:49:43 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-10-22 10:51:16 +0300 |
commit | 044bffc7cd0c2ee09475f72a7666806541f8e78c (patch) | |
tree | 1ee1d667effb373853dbfa4ec9a3f91efc0d6809 | |
parent | f0d3ef2667e5f0a9931cb01d3034707f544ea582 (diff) |
gitaly-hooks: Improve error messages about unexpected args
While we return errors in case we get unexpected arguments in some of
the hooks, these error messages do not state what args we've got. It
would thus be hard to see what went wrong in such a case due to missing
hints.
Improve the error messages by also specifying which args we've got.
-rw-r--r-- | cmd/gitaly-hooks/hooks.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go index b9dda11d7..14aae4d0a 100644 --- a/cmd/gitaly-hooks/hooks.go +++ b/cmd/gitaly-hooks/hooks.go @@ -222,7 +222,7 @@ func check(configPath string) (*gitlab.CheckInfo, error) { func updateHook(ctx context.Context, payload git.HooksPayload, hookClient gitalypb.HookServiceClient, args []string) error { args = args[2:] if len(args) != 3 { - return errors.New("update hook expects exactly three arguments") + return fmt.Errorf("update hook expects exactly three arguments, got %q", args) } ref, oldValue, newValue := args[0], args[1], args[2] @@ -310,7 +310,7 @@ func postReceiveHook(ctx context.Context, payload git.HooksPayload, hookClient g func referenceTransactionHook(ctx context.Context, payload git.HooksPayload, hookClient gitalypb.HookServiceClient, args []string) error { if len(args) != 3 { - return errors.New("reference-transaction hook is missing required arguments") + return fmt.Errorf("reference-transaction hook is missing required arguments, got %q", args) } var state gitalypb.ReferenceTransactionHookRequest_State |