stty/error.go

60 lines
1.1 KiB
Go
Raw Permalink Normal View History

2025-05-05 00:00:56 +03:00
package stty
import (
"fmt"
2025-05-05 00:00:56 +03:00
)
2025-05-08 11:07:19 +03:00
func filterNilErrors(errs []error) (notNilErrs []error) {
for _, err := range errs {
if err != nil {
notNilErrs = append(notNilErrs, err)
}
}
return notNilErrs
}
func Join(errs ...error) (result error) {
errs = filterNilErrors(errs)
if len(errs) == 0 {
return nil
}
for index, err := range errs {
if index == 0 {
result = err
} else {
result = fmt.Errorf("%w: %v", result, err)
2025-05-08 11:07:19 +03:00
}
2025-05-08 11:07:19 +03:00
}
return result
2025-05-05 00:00:56 +03:00
}
func ERR_NOT_TTY() error {
return fmt.Errorf("File is not a tty")
}
func ERR_CANNOT_OPEN_FILE() error {
return fmt.Errorf("Can not open file")
}
func ERR_NO_WRITE_ACCESS() error {
return fmt.Errorf("No write access")
}
func ERR_STTY_MISSING() error {
return fmt.Errorf("Stty is missing")
}
func ERR_BAUDRATE_NOT_SUPPORTED() error {
return fmt.Errorf("Selected baudrate is not supported")
}
func ERR_SET_BAUDRATE_FAILED() error {
return fmt.Errorf("Failed to set baudrate using stty")
}
func ERR_CHECK_BAUDRATE_FAILED() error {
return fmt.Errorf("Failed to check baudrate using stty")
}