Skip to content

Commit

Permalink
Updated error logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
russjones committed Mar 23, 2018
1 parent b53c795 commit f3950d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 10 additions & 1 deletion lib/utils/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ func UserMessageFromError(err error) string {
return trace.DebugReport(err)
}
if err != nil {
return err.Error()
// If the error is a trace error, check if it has a user message embedded in
// it. If a user message is embedded in it, print the user message and the
// original error. Otherwise return the original with a generic "A fatal
// error occured" message.
if er, ok := err.(*trace.TraceErr); ok {
if er.Message != "" {
return fmt.Sprintf("%v: %v", er.Message, er.Err.Error())
}
}
return fmt.Sprintf("A fatal error occurred: %v", err.Error())
}
return ""
}
Expand Down
7 changes: 2 additions & 5 deletions tool/teleport/common/teleport.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ func Run(options Options) (executedCommand string, conf *service.Config) {
if err = config.Configure(&ccf, conf); err != nil {
utils.FatalError(err)
}
if !options.InitOnly {
log.Debug(conf.DebugDumpToYAML())
}
if !options.InitOnly {
err = OnStart(conf)
}
Expand All @@ -170,11 +167,11 @@ func Run(options Options) (executedCommand string, conf *service.Config) {
func OnStart(config *service.Config) error {
srv, err := service.NewTeleport(config)
if err != nil {
return trace.Wrap(err, "initializing teleport")
return trace.Wrap(err, "Initialization failed")
}

if err := srv.Start(); err != nil {
return trace.Wrap(err, "starting teleport")
return trace.Wrap(err, "Startup Failed")
}

return srv.WaitForSignals(context.TODO())
Expand Down

0 comments on commit f3950d1

Please # to comment.