Skip to content

Commit

Permalink
feat: improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Apr 29, 2024
1 parent c01a108 commit 19b394e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions website/src/components/EnvDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ function increment() {
function decrement() {
currentIndex.value = (currentIndex.value + props.envs.length - 1) % props.envs.length
}
</script>>
let prettyError = computed(() => {
if (!props.error) {
return ''
}
// remove leading `Error: ` inject by serde-json
return props.error
.replace(/^(Error: )*/, '')
.split('\n').filter(Boolean).join('\n╰▻ ') // add line break
})
</script>

<template>
<div class="var-debugger">
Expand Down Expand Up @@ -52,7 +61,7 @@ function decrement() {
<button @click="increment">Next Match</button>
</div>
<div v-if="error" class="error-msg">
⚠ {{error}}
⚠ {{prettyError}}
</div>
</div>
</template>
Expand Down Expand Up @@ -88,5 +97,6 @@ function decrement() {
background: var(--vp-custom-block-danger-bg);
margin-top: 5px;
color: var(--vp-c-danger-1);
white-space: pre-wrap;
}
</style>

0 comments on commit 19b394e

Please sign in to comment.