Skip to content

Commit

Permalink
Extract and show error details attr in repl and editor (Fixes #205)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Jul 19, 2023
1 parent ff0f9b9 commit afc77d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shared/studio/tabs/queryEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ const QueryResult = observer(function QueryResult() {
<div className={styles.queryError}>
<span className={styles.errorName}>{result.error.data.name}</span>:{" "}
{result.error.data.msg}
{result.error.data.details ? (
<div className={styles.errorHint}>
Details: {result.error.data.details}
</div>
) : null}
{result.error.data.hint ? (
<div className={styles.errorHint}>
Hint: {result.error.data.hint}
Expand Down
6 changes: 6 additions & 0 deletions shared/studio/tabs/repl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ const ReplHistoryItem = observer(function ReplHistoryItem({
<div className={styles.queryError}>
<span className={styles.errorName}>{item.error.data.name}</span>:{" "}
{item.error.data.msg}
{item.error.data.details ? (
<div className={styles.errorHint}>
Details: {item.error.data.details}
</div>
) : null}
{item.error.data.hint ? (
<div className={styles.errorHint}>Hint: {item.error.data.hint}</div>
) : null}
Expand Down Expand Up @@ -561,6 +566,7 @@ const ReplHistoryItem = observer(function ReplHistoryItem({
>
<div
className={cn(styles.historyOutput, {
[styles.wrapContent]: item.error != null,
[styles.explain]: isExplain,
})}
style={{
Expand Down
4 changes: 4 additions & 0 deletions shared/studio/tabs/repl/repl.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
height: max-content;
height: fit-content;

&.wrapContent {
min-width: auto;
}

.explain {
height: 100%;
display: flex;
Expand Down
5 changes: 5 additions & 0 deletions shared/studio/utils/extractErrorDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface ErrorDetails {
name: string;
msg: string;
hint?: string;
details?: string;
range?: [number, number];
}

Expand Down Expand Up @@ -47,6 +48,10 @@ export function extractErrorDetails(err: any, query: string): ErrorDetails {
if (hint) {
errDetails.hint = utf8Decoder.decode(hint);
}
const details = attrs.get(ErrorField.details);
if (details) {
errDetails.details = utf8Decoder.decode(details);
}

const lineStart = tryParseInt(attrs.get(ErrorField.lineStart));
const lineEnd = tryParseInt(attrs.get(ErrorField.lineEnd));
Expand Down

0 comments on commit afc77d0

Please sign in to comment.