Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de1d37e3 authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor Committed by Jackeagle
Browse files

Resolve incomplete error handling (K1ZFP TODOs)

Several error handlers logged errors but returned false or swallowed
exceptions, masking failures from callers. This caused silent failures
during critical operations like reboot and sideload.

Changes:
- reboot: throw descriptive error instead of returning false
- sideload: throw descriptive error instead of returning false
- bootloader isUnlocked/isLocked: improve error log messages
- bootloader unlock/lock: improve error messages with context
- Remove stale K1ZFP TODO comments throughout

Errors now propagate to the UI layer where they can be displayed to
users, allowing them to understand and potentially retry failed
operations.
parent ab61da36
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ export class Controller {
    WDebug.log("Controller Manager Next", next);

    if (next) {
      //K1ZFP check this
      if (next.mode) {
        //if next step require another mode [adb|fastboot|bootloader]
        if (this.deviceManager.isConnected() && !this.inInMode(next.mode)) {
@@ -143,12 +142,10 @@ export class Controller {
      case Command.CMD_TYPE.reboot:
        try {
          await this.deviceManager.reboot(cmd.mode);
          return true;
        } catch (e) {
          console.error(e);
          //K1ZFP TODO
          return false;
          throw new Error(`Reboot to ${cmd.mode} failed: ${e.message || e}`);
        }
        return true;
      case Command.CMD_TYPE.connect: {
        const proposal =
          "Proposal: Check connection and that no other program is using the phone and retry.";
@@ -256,8 +253,7 @@ export class Controller {
          await this.deviceManager.sideload(cmd.file);
          return true;
        } catch (e) {
          console.error(e); // K1ZFP TODO
          return false;
          throw new Error(`Sideload ${cmd.file} failed: ${e.message || e}`);
        }
      case Command.CMD_TYPE.format:
        try {
+4 −4
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ export class Bootloader extends Device {
        const unlocked = await this.device.getVariable(variable);
        return !(!unlocked || unlocked === "no");
      } catch (e) {
        console.error(e); // K1ZFP TODO
        console.error("isUnlocked check failed:", e);
        throw e;
      }
    }
@@ -117,7 +117,7 @@ export class Bootloader extends Device {
        const unlocked = await this.device.getVariable(variable);
        return !unlocked || unlocked === "no";
      } catch (e) {
        console.error(e); //K1ZFP TODO
        console.error("isLocked check failed:", e);
        throw e;
      }
    }
@@ -128,7 +128,7 @@ export class Bootloader extends Device {
    if (command) {
      await this.device.runCommand(command);
    } else {
      throw Error("no unlock command configured"); //K1ZFP TODO
      throw new Error("No unlock command configured for this device");
    }
  }

@@ -137,7 +137,7 @@ export class Bootloader extends Device {
      await this.device.runCommand(command);
      return !(await this.isUnlocked());
    } else {
      throw Error("no lock command configured"); //K1ZFP TODO
      throw new Error("No lock command configured for this device");
    }
  }
}