-
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 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 |
---|---|---|
|
@@ -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 { | ||
|
@@ -80,6 +81,7 @@ func main() { | |
flags.BoolVar(&cfg.version, "version", false, "Print the version") | ||
flags.BoolVar(&cfg.update, "update", false, "update the cli to the latest version") | ||
flags.StringVar(&cfg.login, "login", "", "Login to Klotho with email. For anonymous login, use 'local'") | ||
_ = flags.MarkHidden("internalDebug") | ||
|
||
err := root.Execute() | ||
if err != nil { | ||
|
@@ -88,6 +90,7 @@ func main() { | |
} else if !root.SilenceErrors { | ||
zap.S().Errorf("%v", err) | ||
} | ||
zap.S().Error("Klotho compilation failed") | ||
os.Exit(1) | ||
} | ||
if hadWarnings.Load() && cfg.strict { | ||
|
@@ -264,8 +267,12 @@ 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) | ||
} else { | ||
err = 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. I feel like this should go similar to the hadWarnings check (line 94) 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. that results in a double print as well though since we already log it. i think if we are treating error log lines and errors the same, having them go through the same flow is fine, it then treats zap errors as actual errors 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. we would also still print the output then if we did it that way which i thought this task is trying to prevent 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. True, we do want to prevent writing the output. I guess this error wouldn't get printed since we don't explicitly print it (like we do for |
||
} | ||
analyticsClient.Error("klotho compiling failed") | ||
|
||
cmd.SilenceErrors = true | ||
|
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.
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 comment
The 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 comment
The 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