Skip to content

Commit

Permalink
add wrappers around errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Lily Pan committed Nov 5, 2024
1 parent 856cb20 commit 8cdad95
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions aks-node-controller/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (a *App) ProvisionWait(ctx context.Context) (string, error) {
if _, err := os.Stat(provisionJSONFilePath); err == nil {
data, err := os.ReadFile(provisionJSONFilePath)
if err != nil {
return "", err
return "", fmt.Errorf("failed to read provision.json: %w", err)
}
return string(data), nil
}
Expand All @@ -121,7 +121,7 @@ func (a *App) ProvisionWait(ctx context.Context) (string, error) {
dir := filepath.Dir(provisionCompleteFilePath)
err = os.MkdirAll(dir, 0755) // create the directory if it doesn't exist
if err != nil {
return "", err
return "", fmt.Errorf("fialed to create directory %s: %w", dir, err)
}
if err = watcher.Add(dir); err != nil {
return "", fmt.Errorf("failed to watch directory: %w", err)
Expand All @@ -133,13 +133,15 @@ func (a *App) ProvisionWait(ctx context.Context) (string, error) {
if event.Op&fsnotify.Create == fsnotify.Create && event.Name == provisionCompleteFilePath {
data, err := os.ReadFile(provisionJSONFilePath)
if err != nil {
return "", err
return "", fmt.Errorf("failed to read provision.json: %w", err)
}
return string(data), nil
}

case err := <-watcher.Errors:
return "", fmt.Errorf("error watching file: %w", err)
case _ = <-ctx.Done():
return "", ctx.Err()
}
}
}
Expand Down

0 comments on commit 8cdad95

Please sign in to comment.