Skip to content

Commit

Permalink
Improved error management
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Aug 30, 2023
1 parent 06af304 commit 7669fc3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions internal/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,20 @@ func GetFeed(basePath string, feedName string, secret string) (*Feed, error) {
} else {
stat, err := os.Stat(path.Join(feedPath, "pin"))
if err != nil {
code := 500
feedLog.Error("Unable to read PIN", slog.Int("return", code))
return nil, &FeedError{
Code: code,
Message: err.Error(),
if os.IsNotExist(err) {
code := 401
feedLog.Error("No PIN configured", slog.Int("return", code))
return nil, &FeedError{
Code: code,
Message: "No PIN configured",
}
} else {
code := 500
feedLog.Error("Unable to read PIN", slog.Int("return", code))
return nil, &FeedError{
Code: code,
Message: err.Error(),
}
}
}

Expand Down

0 comments on commit 7669fc3

Please sign in to comment.