firmware/actions: reuse isError from utils

Remove duplicate isError function.
This commit is contained in:
David Lechner
2026-01-04 17:27:08 -06:00
parent d19ded5908
commit 71a6727a8f
2 changed files with 3 additions and 12 deletions
+1 -10
View File
@@ -4,6 +4,7 @@
import { FirmwareReaderError, HubType } from '@pybricks/firmware';
import { createAction } from '../actions';
import { Hub } from '../components/hubPicker';
import { isError } from '../utils';
export enum MetadataProblem {
Missing = 'metadata.missing',
@@ -144,16 +145,6 @@ export const didFinish = createAction(() => ({
type: 'flashFirmware.action.didFinish',
}));
function isError(err: unknown): err is Error {
const maybeError = err as Error;
return (
maybeError !== undefined &&
typeof maybeError.name === 'string' &&
typeof maybeError.message === 'string'
);
}
// FIXME: get rid of this monstrosity
const didFailToFinishType = 'flashFirmware.action.didFailToFinish';
+2 -2
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2020-2022 The Pybricks Authors
// Copyright (c) 2020-2026 The Pybricks Authors
/**
* Asserts that an assumption is true. This is used to detect programmer errors
@@ -43,7 +43,7 @@ export function hex(n: number, pad: number): string {
return `0x${n.toString(16).padStart(pad, '0')}`;
}
function isError(err: unknown): err is Error {
export function isError(err: unknown): err is Error {
const maybeError = err as Error;
return (