Skip to content

Commit

Permalink
Catch unauthorized error as seen in ubports/ubports-installer#983
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed Oct 28, 2020
1 parent 348dc05 commit 0fb5d8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ function handleError(error, stdout, stderr) {
return "no device";
} else if (stderr && stderr.includes("error: device offline")) {
return "device offline";
} else if (
error &&
error.message &&
error.message.includes("incorrect password")
) {
return "incorrect password";
} else if (
stderr &&
stderr.includes("FAILED (remote: low power, need battery charging.)")
Expand All @@ -66,6 +60,8 @@ function handleError(error, stdout, stderr) {
))
) {
return "bootloader is locked";
} else if (stderr && stderr.includes("error: device unauthorized")) {
return "unauthorized";
} else if (stderr && stderr.includes("FAILED (remote failure)")) {
return "failed to boot";
} else if (
Expand Down
15 changes: 11 additions & 4 deletions tests/unit-tests/test_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@ const recognizedErrors = [
stdout: undefined,
stderr: "error: no devices/emulators found"
},
{
expectedReturn: "unauthorized",
error: { killed: false, code: 1, signal: null, cmd: "command" },
stdout: "",
stderr:
"error: device unauthorized.\nThis adb server's $ADB_VENDOR_KEYS is not set\nTry 'adb kill-server' if that seems wrong.\nOtherwise check for a confirmation dialog on your device."
},
{
expectedReturn: "device offline",
error: { killed: false, code: 1, signal: null, cmd: "command" },
stdout: undefined,
stderr: "error: error: device offline"
},
{
expectedReturn: "incorrect password",
error: { message: "this error includes incorrect password" },
stdout: undefined,
stderr: undefined
expectedReturn: "device offline",
error: { killed: false, code: 1, signal: null, cmd: "command" },
stdout: "",
stderr: "error: error: device offline\n"
},
{
expectedReturn: "bootloader is locked",
Expand Down

0 comments on commit 0fb5d8c

Please sign in to comment.