-
Notifications
You must be signed in to change notification settings - Fork 24
feat: error if the runtime is not found with a missing hook #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -376,20 +376,23 @@ func ExecuteContext(ctx context.Context, rootCmd *cobra.Command, clients *shared | |
|
|
||
| // The cleanup() method in the root command will invoke via `defer` from within Execute. | ||
| if err := rootCmd.ExecuteContext(ctx); err != nil { | ||
| errMsg := err.Error() | ||
| clients.EventTracker.SetErrorMessage(errMsg) | ||
| if slackErr, ok := err.(*slackerror.Error); ok { | ||
| clients.EventTracker.SetErrorCode(slackErr.Code) | ||
| } | ||
| if slackerror.Is(err, slackerror.ErrProcessInterrupted) { | ||
| clients.IO.SetExitCode(iostreams.ExitCancel) | ||
| clients.IO.PrintDebug(ctx, errMsg) | ||
| clients.IO.PrintDebug(ctx, err.Error()) | ||
| } else { | ||
| if slackerror.Is(err, slackerror.ErrSDKHookNotFound) && clients.SDKConfig.Runtime == "" { | ||
| err = slackerror.New(slackerror.ErrRuntimeNotFound). | ||
| WithRootCause(slackerror.ToSlackError(err).WithRemediation("")) | ||
| } | ||
| switch clients.IO.GetExitCode() { | ||
| case iostreams.ExitOK: | ||
| clients.IO.SetExitCode(iostreams.ExitError) | ||
| } | ||
| clients.IO.PrintError(ctx, errMsg) | ||
| clients.IO.PrintError(ctx, err.Error()) | ||
| } | ||
| clients.EventTracker.SetErrorMessage(err.Error()) | ||
| if slackErr, ok := err.(*slackerror.Error); ok { | ||
| clients.EventTracker.SetErrorCode(slackErr.Code) | ||
|
Comment on lines
+393
to
+395
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 note: Moved this since we now might update the |
||
| } | ||
| defer clients.Os.Exit(int(clients.IO.GetExitCode())) | ||
| completedChan <- true | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import ( | |
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| "github.com/opentracing/opentracing-go" | ||
|
|
@@ -306,7 +307,9 @@ func triggerRequestFromFlags(flags createCmdFlags, isDev bool) api.TriggerReques | |
|
|
||
| func triggerRequestViaHook(ctx context.Context, clients *shared.ClientFactory, path string, isDev bool) (api.TriggerRequest, error) { | ||
| if !clients.SDKConfig.Hooks.GetTrigger.IsAvailable() { | ||
| return api.TriggerRequest{}, slackerror.New(slackerror.ErrSDKHookGetTriggerNotFound) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: I like that you've chosen to remove this very-specific hook error for the general
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: Once errors across packages are wrapped I'm optimistic these same details will be clear in output messages 🙏 |
||
| return api.TriggerRequest{}, slackerror.New(slackerror.ErrSDKHookNotFound). | ||
| WithMessage("The `get-trigger` hook script in `%s` was not found", filepath.Join(".slack", "hooks.json")). | ||
| WithRemediation("Try defining your trigger by specifying a json file instead.") | ||
| } | ||
|
|
||
| hookExecOpts := hooks.HookExecOpts{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔏 note: The
runtimeis unknown to actual hook scripts, so theruntime_not_founderror can't be determined during hook execution itself...🤔 question: Does this error handling logic make sense to include at the root command cleanup, or should hook executions be checked for this?