Skip to content

Commit

Permalink
return errs instead of panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Westcott committed Jun 26, 2019
1 parent 5e4cd5b commit cb85074
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions republisher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@ func doIt(ctx context.Context) error {

group, err := setupNotaryGroup(ctx, false)
if err != nil {
panic(errors.Wrap(err, "setting up notary group"))
return errors.Wrap(err, "setting up notary group")
}

configDirs := configdir.New("tupelo", "jasons-game")
folders := configDirs.QueryFolders(configdir.Global)
folder := configDirs.QueryFolderContainsFile(sessionStorageDir)
if folder == nil {
if err := folders[0].CreateParentDir(sessionStorageDir); err != nil {
panic(err)
return err
}
}

sessionPath := filepath.Join(folders[0].Path, sessionStorageDir)

statePath := filepath.Join(sessionPath, filepath.Base("12345"))
if err := os.MkdirAll(statePath, 0750); err != nil {
panic(errors.Wrap(err, "error creating session storage"))
return errors.Wrap(err, "error creating session storage")
}
net, err := network.NewRemoteNetwork(ctx, group, statePath)
if err != nil {
panic(errors.Wrap(err, "setting up network"))
return errors.Wrap(err, "setting up network")
}

err = net.(*network.RemoteNetwork).RepublishAll()
if err != nil {
panic(errors.Wrap(err, "error on publish"))
return errors.Wrap(err, "error on publish")
}
time.Sleep(5 * time.Second)
return nil
Expand Down

0 comments on commit cb85074

Please sign in to comment.