forked from Mirrors/bubbletea
chore(lint): wrap various errors
This commit is contained in:
parent
ffad6555d5
commit
522659d798
8
key.go
8
key.go
|
@ -547,7 +547,7 @@ func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
|
||||||
// Read and block.
|
// Read and block.
|
||||||
numBytes, err := input.Read(buf[:])
|
numBytes, err := input.Read(buf[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("error reading input: %w", err)
|
||||||
}
|
}
|
||||||
b := buf[:numBytes]
|
b := buf[:numBytes]
|
||||||
|
|
||||||
|
@ -558,7 +558,11 @@ func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
|
||||||
select {
|
select {
|
||||||
case msgs <- msg:
|
case msgs <- msg:
|
||||||
case <-ctx.Done():
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package tea
|
package tea
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -32,9 +33,9 @@ type LogOptionsSetter interface {
|
||||||
|
|
||||||
// LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.
|
// LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.
|
||||||
func LogToFileWith(path string, prefix string, log LogOptionsSetter) (*os.File, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("error opening file for logging: %w", err)
|
||||||
}
|
}
|
||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue