-
Notifications
You must be signed in to change notification settings - Fork 40
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
fail if an error log has occured #41
Changes from 2 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 |
---|---|---|
|
@@ -47,10 +47,11 @@ var cfg struct { | |
} | ||
|
||
var hadWarnings = atomic.NewBool(false) | ||
var hadErrors = atomic.NewBool(false) | ||
|
||
func init() { | ||
err := zap.RegisterEncoder("klotho-cli", func(zcfg zapcore.EncoderConfig) (zapcore.Encoder, error) { | ||
return logging.NewConsoleEncoder(cfg.verbose, hadWarnings), nil | ||
return logging.NewConsoleEncoder(cfg.verbose, hadWarnings, hadErrors), nil | ||
}) | ||
|
||
if err != nil { | ||
|
@@ -83,11 +84,7 @@ func main() { | |
|
||
err := root.Execute() | ||
if err != nil { | ||
if cfg.internalDebug { | ||
zap.S().Errorf("%+v", err) | ||
} else if !root.SilenceErrors { | ||
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. Doesn't this regress the silence errors (which we set on line 270 so it doesn't double-print)? 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. nope, we still set that to make sure that we dont double print anything 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. yeah we actually will want this so that the non plugin errors surface, going to add it back |
||
zap.S().Errorf("%v", err) | ||
} | ||
zap.S().Error("Klotho compilation failed") | ||
os.Exit(1) | ||
} | ||
if hadWarnings.Load() && cfg.strict { | ||
|
@@ -264,13 +261,15 @@ func run(cmd *cobra.Command, args []string) (err error) { | |
analyticsClient.Info("klotho compiling") | ||
|
||
result, err := compiler.Compile(input) | ||
if err != nil { | ||
errHandler.PrintErr(err) | ||
if err != nil || hadErrors.Load() { | ||
if err != nil { | ||
errHandler.PrintErr(err) | ||
} | ||
analyticsClient.Error("klotho compiling failed") | ||
|
||
cmd.SilenceErrors = true | ||
cmd.SilenceUsage = true | ||
return err | ||
return errors.New("Failed run of klotho invocation") | ||
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. because we always set SilenceErrors to true it shouldnt matter what we return, just that we return some error |
||
} | ||
|
||
if cfg.uploadSource { | ||
|
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.
i was confused on why we have this. just reprints errors it looks like so i removed it. If theres a reason to have it ill add it back and have to change my implementation
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.
The difference is in the format:
%+v
vs%v
. The+
gives a full stack trace, which is only relevant for us developers and not for users.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.
so do we want to have it as a cli flag then? because this could be exposed to the end user right?