Skip to content

Commit 4ef84f5

Browse files
committed
handle incorrect resource types
1 parent 39c0a0a commit 4ef84f5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

frontend/src/lib/components/ObjectResourceInput.svelte

+17-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { ToggleButton, ToggleButtonGroup } from './common'
77
import ResourcePicker from './ResourcePicker.svelte'
88
import SchemaForm from './SchemaForm.svelte'
9+
import SimpleEditor from './SimpleEditor.svelte'
910
1011
export let format: string
1112
export let value: any
@@ -28,9 +29,16 @@
2829
2930
async function loadSchema(format: string) {
3031
resourceTypeName = format.substring('resource-'.length)
31-
schema = (
32-
await ResourceService.getResourceType({ workspace: $workspaceStore!, path: resourceTypeName })
33-
).schema
32+
try {
33+
schema = (
34+
await ResourceService.getResourceType({
35+
workspace: $workspaceStore!,
36+
path: resourceTypeName
37+
})
38+
).schema
39+
} catch (e) {
40+
schema = undefined
41+
}
3442
}
3543
3644
function argToValue() {
@@ -91,8 +99,12 @@
9199
/>
92100
{:else}
93101
<div class="border rounded p-2 w-full">
94-
{#if !isString(args)}
95-
<SchemaForm {compact} {schema} bind:isValid bind:args />
102+
{#if schema != undefined}
103+
{#if !isString(args)}
104+
<SchemaForm {compact} {schema} bind:isValid bind:args />
105+
{/if}
106+
{:else}
107+
<SimpleEditor autoHeight lang="json" bind:value={args} />
96108
{/if}
97109
</div>
98110
{/if}

0 commit comments

Comments
 (0)