-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add dedicated view for errors (#93)
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe> Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
- Loading branch information
1 parent
e436ab9
commit 93a2f60
Showing
9 changed files
with
124 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup lang="ts"> | ||
import type { ParsedError } from '../../types' | ||
defineProps<{ | ||
error: ParsedError | ||
}>() | ||
function normalizeFilename(filename?: string) { | ||
return (filename || '') | ||
.replace(/^async\s+/, '') | ||
.replace(/^file:\/\//, '') | ||
} | ||
</script> | ||
|
||
<template> | ||
<div of-auto p4 font-mono flex="~ col gap-4"> | ||
<div text-xl text-red7 dark:text-red flex="~ gap-2 items-center"> | ||
<div i-carbon:warning-square /> | ||
Error | ||
</div> | ||
<pre text-sm text-red7 dark:text-red>{{ error.message }}</pre> | ||
<div border="t main" h-1px w-full /> | ||
<div class="text-xs" mt2 grid="~ cols-[max-content_1fr] gap-x-4 gap-y-1" font-mono> | ||
<template v-for="item, idx of error.stack" :key="idx"> | ||
<div text-right op50> | ||
{{ item.functionName || `(anonymous)` }} | ||
</div> | ||
<div ws-nowrap> | ||
<FilepathItem | ||
:filepath="normalizeFilename(item.fileName)" | ||
:line="item.lineNumber" | ||
:column="item.columnNumber" | ||
/> | ||
</div> | ||
</template> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup lang="ts"> | ||
const props = defineProps<{ | ||
filepath: string | ||
line?: number | ||
column?: number | ||
}>() | ||
async function openInEditor() { | ||
await fetch(`/__open-in-editor?file=${encodeURI(props.filepath)}:${props.line}:${props.column}`) | ||
} | ||
const display = computed(() => { | ||
const path = props.filepath.replace(/\\/g, '/') | ||
if (props.filepath.includes('/node_modules/')) { | ||
const match = path.match(/.*\/node_modules\/(@[^/]+\/[^/]+|[^/]+)(\/.*)?$/) | ||
if (match) | ||
return [match[1], match[2]] | ||
} | ||
return [path] | ||
}) | ||
</script> | ||
|
||
<template> | ||
<button flex="~" hover="underline" @click="openInEditor"> | ||
<span>{{ display[0] }}</span> | ||
<span op60>{{ display[1] }}</span> | ||
<span v-if="props.line != null && props.column != null" op50>:{{ props.line }}:{{ props.column }}</span> | ||
</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters