Skip to content

Commit

Permalink
fix: handle createQuery throwing an exception in the TransformModal
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Sep 25, 2024
1 parent 5dc2262 commit 4b1f3f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/lib/components/modals/TransformModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
}
}

.query-error {
color: $error-color;
}

textarea.jse-query {
flex: 1;
outline: none;
Expand Down
20 changes: 16 additions & 4 deletions src/lib/components/modals/TransformModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
state.queryOptions || {}
)
let isManual = state.isManual || false
let queryError: string | undefined = undefined
let previewError: string | undefined = undefined
let previewContent: Content = { text: '' }
Expand All @@ -96,11 +97,17 @@
}
function updateQueryByWizard(newQueryOptions: QueryLanguageOptions) {
queryOptions = newQueryOptions
query = getSelectedQueryLanguage(queryLanguageId).createQuery(selectedJson, newQueryOptions)
isManual = false
try {
queryOptions = newQueryOptions
query = getSelectedQueryLanguage(queryLanguageId).createQuery(selectedJson, newQueryOptions)
queryError = undefined
isManual = false
debug('updateQueryByWizard', { queryOptions, query, isManual })
debug('updateQueryByWizard', { queryOptions, query, isManual })
} catch (err) {
queryError = String(err)
}
}
function handleChangeQuery(event: Event) {
Expand Down Expand Up @@ -271,6 +278,11 @@
json={selectedJson}
onChange={updateQueryByWizard}
/>
{#if queryError}
<div class="query-error">
{queryError}
</div>
{/if}
{:else}
(Only available for arrays, not for objects)
{/if}
Expand Down

0 comments on commit 4b1f3f6

Please sign in to comment.