mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
firmware/actions: reuse isError from utils
Remove duplicate isError function.
This commit is contained in:
+1
-10
@@ -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
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user