Skip to content

Commit fadc3bc

Browse files
afaragodlech
authored andcommitted
firmware/installPybricksDialog/hooks: dispatch error if no url
Dispatch an error in case there is no firmware URL. Normally this should never happen, but currently it does because we don't have EV3 firmware yet. The error is more useful than just spinning forever.
1 parent c630223 commit fadc3bc

File tree

1 file changed

+4
-2
lines changed
  • src/firmware/installPybricksDialog

1 file changed

+4
-2
lines changed

src/firmware/installPybricksDialog/hooks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2022-2023 The Pybricks Authors
2+
// Copyright (c) 2022-2025 The Pybricks Authors
33
// based on https://usehooks-ts.com/react-hook/use-fetch
44

55
import { FirmwareMetadata, FirmwareReader } from '@pybricks/firmware';
@@ -78,8 +78,10 @@ export function useFirmware(hubType: Hub): State {
7878
const [state, dispatch] = useReducer(fetchReducer, initialState);
7979

8080
useEffect(() => {
81-
// Do nothing if the url is not given
81+
// Raise error if the url is not given, to show that something is wrong
82+
// instead of a misleading intermediate state.
8283
if (!url) {
84+
dispatch({ type: 'error', payload: new Error('No URL for this hub type') });
8385
return;
8486
}
8587

0 commit comments

Comments
 (0)