Skip to content

Commit

Permalink
sound/image error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
mayarajan3 committed Aug 7, 2024
1 parent db77a19 commit ced4fbb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
40 changes: 40 additions & 0 deletions extensions/src/doodlebot/ArrayError.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script lang="ts">
import type Extension from ".";
import {
ReactiveInvoke,
reactiveInvoke,
activeClass,
color,
} from "$common";
import { onDestroy } from "svelte";
export let extension: Extension;
export let close: () => void;
const invoke: ReactiveInvoke<Extension> = (functionName, ...args) =>
reactiveInvoke((extension = extension), functionName, args);
const container = activeClass;
onDestroy(() => {
console.log("Closed");
});
</script>

<div
class:container
style:width="50vw"
style:background-color={color.ui.white}
style:color={color.text.primary}
>
<h1>Cannot load Doodlebot's sound/image server!</h1>
<h2>Please try reloading the page.</h2>
</div>

<style>
.container {
text-align: center;
padding: 30px;
}
</style>
3 changes: 1 addition & 2 deletions extensions/src/doodlebot/Doodlebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,7 @@ export default class Doodlebot {

return itemNames;
} catch (error) {
console.error('Error fetching or parsing HTML:', error);
return [];
throw new Error('Error fetching or parsing HTML:', error)
}
}

Expand Down
8 changes: 6 additions & 2 deletions extensions/src/doodlebot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ export default class DoodlebotBlocks extends extension(details, "ui", "customArg
async setDoodlebot(doodlebot: Doodlebot) {
this.doodlebot = doodlebot;
this.setIndicator("connected");
imageFiles = await doodlebot.findImageFiles();
soundFiles = await doodlebot.findSoundFiles();
try {
imageFiles = await doodlebot.findImageFiles();
soundFiles = await doodlebot.findSoundFiles();
} catch (e) {
this.openUI("ArrayError");
}
console.log("SETTING");
console.log(soundFiles);
}
Expand Down

0 comments on commit ced4fbb

Please sign in to comment.