Skip to content

Commit

Permalink
Rename to match usage
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-matt-hillsdon committed Jul 11, 2024
1 parent afa37db commit 27cf783
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/hex-flash-data-source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { BoardId } from "./board-id";
import { FlashDataSource, HexGenerationError } from "./device";
import {
FlashDataSource,
HexGenerationError as FlashDataError,
} from "./device";
import {
isUniversalHex,
separateUniversalHex,
Expand All @@ -23,11 +26,11 @@ export class HexFlashDataSource implements FlashDataSource {
const keys = Array.from(hex.keys()).filter((k) => k < 0x10000000);
const lastKey = keys[keys.length - 1];
if (lastKey === undefined) {
throw new HexGenerationError("Empty hex");
throw new FlashDataError("Empty hex");
}
const lastPart = hex.get(lastKey);
if (!lastPart) {
throw new HexGenerationError("Empty hex");
throw new FlashDataError("Empty hex");
}
const length = lastKey + lastPart.length;
const data = hex.slicePad(0, length, 0);
Expand All @@ -44,7 +47,7 @@ export class HexFlashDataSource implements FlashDataSource {
const parts = separateUniversalHex(this.hex);
const matching = parts.find((p) => p.boardId == boardId.normalize().id);
if (!matching) {
throw new HexGenerationError("No matching part");
throw new FlashDataError("No matching part");
}
return matching.hex;
}
Expand Down

0 comments on commit 27cf783

Please sign in to comment.