Skip to content

Commit 68e8e36

Browse files
committed
chore: add instructions for overriding errors
1 parent 1e250f6 commit 68e8e36

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

src/tutorials/boilerplates/boilerplate-file-upload.vue

+19-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
:validate="validate"
66
:modules="modules"
77
:exercise="exercise"
8-
lessonTitle="REPLACEME">
9-
</FileLesson>
8+
lessonTitle="REPLACEME" />
109
</template>
1110

1211
<script>
@@ -17,10 +16,24 @@ import exercise from './REPLACEME-exercise.md'
1716
1817
const validate = async (result, ipfs) => {
1918
if (result) {
20-
return {'success': 'Happy Message!'}
19+
return { success: 'Happy Message!' }
2120
} else {
22-
return {'fail': 'Sad but useful message :('}
21+
return { fail: 'Sad but useful message :(' }
2322
}
23+
24+
/*
25+
By default, if any external error occurs its output will be shown.
26+
If you want to catch those erros and override them to show something
27+
else to the users, add the following attribute in the FileLesson component:
28+
29+
<FileLesson :overrideErrors="true" ... />
30+
31+
Here in the `validate` function, add the folowing lines below the validation
32+
if you enabled the overriding of errors:
33+
34+
// Output the default error if we haven't catched any
35+
return { error: result.error }
36+
*/
2437
}
2538
2639
const code = `const run = async (files) => {
@@ -29,16 +42,14 @@ const code = `const run = async (files) => {
2942
return run
3043
`
3144
32-
const modules = {cids: require('cids')}
45+
const modules = { cids: require('cids') }
3346
3447
export default {
3548
components: {
3649
Lesson
3750
},
3851
data: () => {
39-
return {
40-
text, validate, code, modules, exercise
41-
}
52+
return { text, validate, code, modules, exercise }
4253
}
4354
}
4455
</script>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
22
<Lesson
33
:text="text"
4-
lessonTitle="REPLACEME">
5-
</Lesson>
4+
lessonTitle="REPLACEME" />
65
</template>
76

87
<script>
@@ -14,9 +13,7 @@ export default {
1413
Lesson
1514
},
1615
data: () => {
17-
return {
18-
text
19-
}
16+
return { text }
2017
}
2118
}
2219
</script>

src/tutorials/boilerplates/boilerplate-standard.vue

+19-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
:validate="validate"
66
:modules="modules"
77
:exercise="exercise"
8-
lessonTitle="REPLACEME">
9-
</Lesson>
8+
lessonTitle="REPLACEME" />
109
</template>
1110

1211
<script>
@@ -16,10 +15,24 @@ import exercise from './REPLACEME-exercise.md'
1615
1716
const validate = async (result, ipfs) => {
1817
if (result) {
19-
return {'success': 'Happy Message!'}
18+
return { success: 'Happy Message!' }
2019
} else {
21-
return {'fail': 'Sad but useful message :('}
20+
return { fail: 'Sad but useful message :(' }
2221
}
22+
23+
/*
24+
By default, if any external error occurs its output will be shown.
25+
If you want to catch those erros and override them to show something
26+
else to the users, add the following attribute in the FileLesson component:
27+
28+
<FileLesson :overrideErrors="true" ... />
29+
30+
Here in the `validate` function, add the folowing lines below the validation
31+
if you enabled the overriding of errors:
32+
33+
// Output the default error if we haven't catched any
34+
return { error: result.error }
35+
*/
2336
}
2437
2538
const code = `const CID = require('cids')
@@ -30,16 +43,14 @@ const run = async () => {
3043
return run
3144
`
3245
33-
const modules = {cids: require('cids')}
46+
const modules = { cids: require('cids') }
3447
3548
export default {
3649
components: {
3750
Lesson
3851
},
3952
data: () => {
40-
return {
41-
text, validate, code, modules
42-
}
53+
return { text, validate, code, modules }
4354
}
4455
}
4556
</script>

0 commit comments

Comments
 (0)