2025-05-05 00:00:56 +03:00
|
|
|
package stty
|
|
|
|
|
|
|
|
import(
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2025-05-05 01:22:01 +03:00
|
|
|
type unwraperr interface {
|
|
|
|
Unwrap() error
|
|
|
|
}
|
|
|
|
|
|
|
|
type unwraperrs interface {
|
|
|
|
Unwrap() []error
|
|
|
|
}
|
|
|
|
|
|
|
|
func isUnwrapable(err error) bool {
|
|
|
|
_, ok1 := err.(unwraperr)
|
|
|
|
_, ok2 := err.(unwraperrs)
|
|
|
|
return ok1 || ok2
|
|
|
|
}
|
|
|
|
|
2025-05-05 00:00:56 +03:00
|
|
|
func errStack(err1 error, err2 error) error {
|
2025-05-05 01:22:01 +03:00
|
|
|
if isUnwrapable(err2) {
|
|
|
|
return fmt.Errorf("%w: %w", err1, err2)
|
|
|
|
}
|
|
|
|
return fmt.Errorf("%w: %v", err1, err2)
|
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")
|
|
|
|
}
|