File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
const runs = ref ([]);
3
+ const error = ref (null );
3
4
4
5
const handleRequestFormSubmit = async ({ url }): void => {
5
6
if (! url .startsWith (" http" )) {
@@ -19,9 +20,13 @@ const handleRequestFormSubmit = async ({ url }): void => {
19
20
cacheHeaders: getCacheHeaders (responseBody .headers ),
20
21
durationInMs: responseBody .durationInMs ,
21
22
});
23
+
24
+ error .value = null ;
22
25
} catch (err ) {
23
- // TODO(serhalp) Proper error handling. ErrorBoundary?
24
- console .error (" Error fetching URL" , err );
26
+ error .value =
27
+ err ?.data ?.message ??
28
+ err ?.toString ?.() ??
29
+ new Error (` Fetch error: ${err } ` );
25
30
return ;
26
31
}
27
32
};
@@ -45,6 +50,10 @@ const handleClickClear = (): void => {
45
50
<main >
46
51
<RequestForm @submit =" handleRequestFormSubmit" />
47
52
53
+ <div v-if =" error" class =" error" >
54
+ {{ error }}
55
+ </div >
56
+
48
57
<div class =" flex-btwn run-panels" >
49
58
<RunPanel v-for =" run in runs" v-bind =" run" />
50
59
</div >
@@ -76,6 +85,10 @@ main {
76
85
padding-bottom : 3em ;
77
86
}
78
87
88
+ .error {
89
+ color : var (--red-400 );
90
+ }
91
+
79
92
.run-panels {
80
93
flex-wrap : wrap ;
81
94
align-items : stretch ;
You can’t perform that action at this time.
0 commit comments