Skip to content

Commit

Permalink
internal/config: refactored errors to use exit.Wrapf
Browse files Browse the repository at this point in the history
  • Loading branch information
azazeal committed Aug 29, 2021
1 parent 632cb5c commit c2ea402
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config

import (
"context"
"errors"
"math"
"os"
"strconv"
Expand Down Expand Up @@ -68,20 +67,20 @@ func NewContext(ctx context.Context, cfg *Config) context.Context {
return context.WithValue(ctx, contextKeyType{}, cfg)
}

const (
pkg = "config"
errorPrefix = common.AppName + "/" + pkg + ": "
)
const pkg = "config"

var (
errSetDefaults = exit.Wrap(common.ECSetEnvDefaults,
errors.New(errorPrefix+"failed setting environment defaults"))
errSetDefaults = exit.Wrapf(common.ECSetEnvDefaults,
"%s/%s: failed setting environment defaults",
common.AppName, pkg)

errNotOnFly = exit.Wrap(common.ECNotOnFly,
errors.New(errorPrefix+"not running on fly"))
errNotOnFly = exit.Wrapf(common.ECNotOnFly,
"%s/%s: not running on fly",
common.AppName, pkg)

errLoadConfig = exit.Wrap(common.ECConfig,
errors.New(errorPrefix+"failed loading configuration"))
errLoadConfig = exit.Wrapf(common.ECConfig,
"%s/%s: failed loading configuration",
common.AppName, pkg)
)

// Load loads the configuration from the environment.
Expand Down

0 comments on commit c2ea402

Please sign in to comment.