goadb/wire/adb_error.go

25 lines
505 B
Go
Raw Normal View History

package wire
import (
"fmt"
)
type AdbError struct {
2015-04-29 17:23:51 +00:00
Request string
ServerMsg string
}
var _ error = &AdbError{}
func (e *AdbError) Error() string {
2015-04-29 17:23:51 +00:00
if e.Request == "" {
return fmt.Sprintf("server error: %s", e.ServerMsg)
} else {
2015-04-29 17:23:51 +00:00
return fmt.Sprintf("server error for %s request: %s", e.Request, e.ServerMsg)
}
}
func incompleteMessage(description string, actual int, expected int) error {
return fmt.Errorf("incomplete %s: read %d bytes, expecting %d", description, actual, expected)
}