66 "os"
77 "strings"
88
9+ "github.com/google/uuid"
910 "github.com/thoas/go-funk"
1011
1112 "github.com/ActiveState/cli/internal/analytics"
@@ -32,6 +33,16 @@ type OutputError struct {
3233 error
3334}
3435
36+ var errorId string
37+
38+ func getErrorId () string {
39+ if errorId == "" {
40+ errorId = uuid .New ().String ()[:8 ]
41+ }
42+
43+ return errorId
44+ }
45+
3546func (o * OutputError ) MarshalOutput (f output.Format ) interface {} {
3647 var outLines []string
3748 isInputError := locale .IsInputError (o .error )
@@ -68,7 +79,11 @@ func (o *OutputError) MarshalOutput(f output.Format) interface{} {
6879
6980 // Concatenate error tips
7081 errorTips := getErrorTips (o .error )
71- errorTips = append (errorTips , locale .Tl ("err_help_forum" , "Ask For Help → [ACTIONABLE]{{.V0}}[/RESET]" , constants .ForumsURL ))
82+ helpMsg := locale .Tl ("err_help_forum" , "Ask For Help → [ACTIONABLE]{{.V0}}[/RESET]" , constants .ForumsURL )
83+ if IsReportableError (o .error ) {
84+ helpMsg += "\n " + locale .Tl ("err_help_error_id" , "When doing so, please reference the following error ID: {{.V0}}" , getErrorId ())
85+ }
86+ errorTips = append (errorTips , helpMsg )
7287
7388 // Print tips
7489 enableTips := os .Getenv (constants .DisableErrorTipsEnvVarName ) != "true" && f == output .PlainFormatName
@@ -197,7 +212,7 @@ func ReportError(err error, cmd *captain.Command, an analytics.Dispatcher) {
197212 var action string
198213 errorMsg := err .Error ()
199214 if IsReportableError (err ) {
200- multilog .Critical ("Returning error: \n %s\n Created at:\n %s" , errs .JoinMessage (err ), stack )
215+ multilog .Critical ("Returning error (ID: %s): \n %s\n Created at:\n %s" , getErrorId () , errs .JoinMessage (err ), stack )
201216 action = anaConst .ActCommandError
202217 } else {
203218 logging .Debug ("Returning input error:\n %s\n Created at:\n %s" , errs .JoinMessage (err ), stack )
0 commit comments