Skip to content

Commit

Permalink
Trim output when logging ADB errors + add exit code to adb errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauriethefish committed Dec 20, 2023
1 parent ac5309b commit 6bf3d73
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions QuestPatcher.Core/AndroidDebugBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public async Task<ProcessOutput> RunCommand(string command, params int[] allowed
// -1073740940 is always allowed as some ADB installations return it randomly, even when commands are successful.
if (output.ExitCode == 0 || allowedExitCodes.Contains(output.ExitCode) || output.ExitCode == -1073740940) { return output; }

string allOutput = output.StandardOutput + output.ErrorOutput;
string allOutput = (output.StandardOutput + output.ErrorOutput).Trim();

// We repeatedly prompt the user to plug in their quest if it is not plugged in, or the device is offline, or if there are multiple devices
if (allOutput.Contains("no devices/emulators found"))
Expand All @@ -295,7 +295,8 @@ public async Task<ProcessOutput> RunCommand(string command, params int[] allowed
else
{
// Throw an exception as ADB gave a non-zero exit code so the command must've failed
throw new AdbException(allOutput);
// Add the exit code to the error message for debugging purposes.
throw new AdbException($"Code {output.ExitCode}: {allOutput}");
}
}
}
Expand Down

0 comments on commit 6bf3d73

Please sign in to comment.