Add error wrapping in app

This commit is contained in:
mcrakhman 2023-03-16 18:46:48 +01:00 committed by Mikhail Iudin
parent 6d6fd1e849
commit aa4817e1e6
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -172,7 +172,7 @@ func (app *App) Start(ctx context.Context) (err error) {
for i, s := range app.components { for i, s := range app.components {
if err = s.Init(app); err != nil { if err = s.Init(app); err != nil {
closeServices(i) closeServices(i)
return fmt.Errorf("can't init service '%s': %v", s.Name(), err) return fmt.Errorf("can't init service '%s': %w", s.Name(), err)
} }
} }
@ -181,7 +181,7 @@ func (app *App) Start(ctx context.Context) (err error) {
start := time.Now() start := time.Now()
if err = serviceRun.Run(ctx); err != nil { if err = serviceRun.Run(ctx); err != nil {
closeServices(i) closeServices(i)
return fmt.Errorf("can't run service '%s': %v", serviceRun.Name(), err) return fmt.Errorf("can't run service '%s': %w", serviceRun.Name(), err)
} }
spent := time.Since(start).Milliseconds() spent := time.Since(start).Milliseconds()
app.startStat.SpentMsTotal += spent app.startStat.SpentMsTotal += spent