goadb/wire/adb_error.go
2015-05-03 05:37:53 -07:00

25 lines
505 B
Go

package wire
import (
"fmt"
)
type AdbError struct {
Request string
ServerMsg string
}
var _ error = &AdbError{}
func (e *AdbError) Error() string {
if e.Request == "" {
return fmt.Sprintf("server error: %s", e.ServerMsg)
} else {
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)
}