Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dave committed Oct 27, 2017
1 parent bba8f3e commit dba25f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions blaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/leemcloughlin/gofarmhash"
"github.com/pkg/errors"
"github.com/spf13/viper"
)

Expand Down Expand Up @@ -117,6 +118,10 @@ func (b *Blaster) Start(ctx context.Context) error {
return err
}

if b.config.Data == "" {
return errors.New("No data file specified. Use --config to view current config.")
}

if err := b.openDataFile(ctx); err != nil {
return err
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/blast/blast.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import (

"fmt"

"os"

"github.com/dave/blast"
"github.com/dave/blast/dummyworker"
"github.com/dave/blast/httpworker"
)

const DEBUG = false

func main() {
ctx, cancel := context.WithCancel(context.Background())

Expand All @@ -21,6 +25,11 @@ func main() {
b.RegisterWorkerType("http", httpworker.New)

if err := b.Start(ctx); err != nil {
log.Fatal(fmt.Printf("%+v", err))
if DEBUG {
log.Fatal(fmt.Printf("%+v", err))
} else {
fmt.Println(err)
os.Exit(1)
}
}
}

0 comments on commit dba25f0

Please sign in to comment.