-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.vue
225 lines (201 loc) · 6.33 KB
/
error.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<script setup lang="ts">
import type { NuxtError } from '#app';
const props = defineProps({
error: Object as () => NuxtError
});
const { error } = props;
const handleError = () => clearError({ redirect: '/' });
const copyError = () => {
navigator.clipboard.writeText(JSON.stringify(error, null, 2));
const button = document.getElementById('copy-err-button');
if (button) {
button.textContent = 'Error info copied!';
setTimeout(() => {
button.textContent = 'Copy error info';
}, 2000);
}
}
</script>
<template>
<div class="outer">
<Title>
Techmino Hub - Error {{ error?.statusCode }}
</Title>
<div class="main-panel">
<Background />
<Header class="error" />
<main>
<h1>
Error {{ error?.statusCode }}
</h1>
<p v-if="error?.statusCode === 404">
The page you are looking for does not exist. <br>
You may have stumbled onto an unfinished page.
</p>
<a v-else :href="`https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/${error?.statusCode}`">
Learn more about HTTP status code {{ error?.statusCode }}
</a>
<pre><code class="error-code">{{ error?.message }}</code></pre>
<div v-if="error?.stack !== undefined && error.statusCode !== 404">
The call stack when the error occured is as follows:
<div class="stack" v-html="error.stack"></div>
</div>
<hr>
<div class="error-bottom">
<menu class="error-buttons">
<NuxtLinkLocale @click="handleError" to="/" class="home">
Go back to home
</NuxtLinkLocale>
<button @click="copyError" class="copy hide-noscript" id="copy-err-button">
Copy error info
</button>
<NuxtLink to="https://github.com/techmino-hub/techmino-hub-source-code/issues/new" class="report">
Report error on GitHub
</NuxtLink>
</menu>
<details>
<summary>
Raw error info
</summary>
<pre><code class="error-details">{{ error }}</code></pre>
</details>
</div>
</main>
<Footer />
</div>
</div>
</template>
<style scoped lang="scss">
@use "~/assets/scss/main";
@use "~/assets/scss/colors" as colors;
@use "~/assets/scss/global";
main {
padding: 1em 2em;
a {
color: colors.$primary-color;
transition-duration: 200ms;
border-radius: 0.5em;
padding: 0.25em 0.4em;
&:hover {
background-color: colors.$primary-color-alpha25;
}
&:active {
background-color: colors.$primary-color-alpha50;
}
}
}
pre {
font-family: 'techmino-monospace', monospace, sans-serif;
white-space: pre-wrap;
word-break: break-word;
}
code.error-code {
display: block;
border: 0.15em dashed colors.$error-color;
border-radius: 0.5em;
background-color: black;
padding: 1em;
font-size: 1.5em;
}
code.error-details {
display: block;
border-radius: 0.5em;
background-color: black;
padding: 0.5em;
font-size: 1.25em;
}
div.stack {
border: 0.15em solid colors.$error-color;
border-radius: 0.5em;
background-color: colors.$error-color-alpha25;
padding: 0.25em 1em;
margin-top: 1em;
}
.error-bottom {
position: relative;
display: flex;
margin-inline: auto;
flex-direction: column;
max-width: 40em;
gap: 1em;
border: 0.15em solid colors.$secondary-color;
border-radius: 0.5em;
background-color: colors.$secondary-color-alpha50;
padding: 1em;
details {
font-weight: bold;
padding: 0.25em;
background-color: colors.$error-color-alpha25;
border: 0.15em solid colors.$error-color;
border-radius: 0.5em;
summary {
cursor: pointer;
}
pre {
margin-bottom: 0;
}
}
}
.error-buttons {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 1em;
row-gap: 1em;
padding: 0; margin: 0;
flex-wrap: wrap;
> * {
color: white;
padding: 0.5em 1em;
border: 0.15em solid colors.$secondary-color;
border-radius: 0.5em;
background-color: colors.$secondary-color;
text-align: center;
text-decoration: none;
transition: background-color 200ms, color 200ms, box-shadow 200ms;
cursor: pointer;
&.home {
background-color: colors.$primary-color-alpha25;
border-color: colors.$primary-color;
&:hover {
box-shadow: 0 0 0.5em colors.$primary-color;
}
&:active {
box-shadow: 0 0 0.5em colors.$primary-color-dark;
background-color: colors.$primary-color-alpha50;
}
}
&.copy {
background-color: colors.$tertiary-color-alpha25;
border-color: colors.$tertiary-color;
font-family: 'techmino-proportional';
font-size: 1em;
&:hover {
box-shadow: 0 0 0.5em colors.$tertiary-color;
}
&:active {
box-shadow: 0 0 0.5em colors.$tertiary-color-dark;
background-color: colors.$tertiary-color-alpha75;
}
}
&.report {
$gh-color-dark: #111;
$gh-color-light: #ddd;
background-color: $gh-color-dark;
border-color: $gh-color-light;
color: $gh-color-light;
transition-duration: 350ms;
&:hover {
box-shadow: 0 0 0.5em $gh-color-light;
}
&:active {
box-shadow: 0 0 2em $gh-color-dark;
background-color: $gh-color-light;
border-color: $gh-color-dark;
color: $gh-color-dark;
}
}
}
}
</style>