Skip to content

Commit

Permalink
chore(lint): wrap various errors
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Jul 7, 2023
1 parent ccc9251 commit 75d3be8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
// Read and block.
numBytes, err := input.Read(buf[:])
if err != nil {
return err
return fmt.Errorf("error reading input: %w", err)
}
b := buf[:numBytes]

Expand All @@ -558,7 +558,11 @@ func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
select {
case msgs <- msg:
case <-ctx.Done():
return ctx.Err()
err := ctx.Err()
if err != nil {
err = fmt.Errorf("found context error while reading input: %w", err)
}
return err
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions logging.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tea

import (
"fmt"
"io"
"log"
"os"
Expand Down Expand Up @@ -32,9 +33,9 @@ type LogOptionsSetter interface {

// LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.
func LogToFileWith(path string, prefix string, log LogOptionsSetter) (*os.File, error) {
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644)
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644) //nolint:gomnd
if err != nil {
return nil, err
return nil, fmt.Errorf("error opening file for logging: %w", err)
}
log.SetOutput(f)

Expand Down

0 comments on commit 75d3be8

Please sign in to comment.