mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
refactor: hrp code
This commit is contained in:
@@ -90,7 +90,7 @@ func (c Client) DeviceSerialList() (serials []string, err error) {
|
||||
func (c Client) DeviceList() (devices []*Device, err error) {
|
||||
defer func() {
|
||||
if err != nil && errors.Cause(err) == nil {
|
||||
err = errors.Wrap(code.AndroidDeviceConnectionError, err.Error())
|
||||
err = errors.Wrap(code.DeviceConnectionError, err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ func (d *Device) ReverseForwardKillAll() error {
|
||||
func (d *Device) RunShellCommand(cmd string, args ...string) (string, error) {
|
||||
raw, err := d.RunShellCommandWithBytes(cmd, args...)
|
||||
if err != nil && errors.Cause(err) == nil {
|
||||
err = errors.Wrap(code.AndroidShellExecError, err.Error())
|
||||
err = errors.Wrap(code.DeviceShellExecError, err.Error())
|
||||
}
|
||||
return string(raw), err
|
||||
}
|
||||
|
||||
@@ -42,18 +42,18 @@ func newTransport(address string, readTimeout ...time.Duration) (tp transport, e
|
||||
|
||||
// connection refused
|
||||
if strings.Contains(err.Error(), "connect: connection refused") {
|
||||
err = errors.Wrap(code.AndroidDeviceConnectionRefusedError, err.Error())
|
||||
err = errors.Wrap(code.DeviceConnectionError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// device offline
|
||||
if regexDeviceOffline.MatchString(err.Error()) {
|
||||
err = errors.Wrap(code.AndroidDeviceOfflineError, err.Error())
|
||||
err = errors.Wrap(code.DeviceOfflineError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// other connection errors
|
||||
err = errors.Wrap(code.AndroidDeviceConnectionError, err.Error())
|
||||
err = errors.Wrap(code.DeviceConnectionError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user