File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed
exercises/03.advanced-tools
04.solution.errors/src/db Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ For this step:
1515This will make your journaling app more robust and user-friendly, and help LLMs
1616handle problems gracefully.
1717
18+ <callout-info >
19+ ℹ️ In this exercise, you can simulate an error by trying to submit a tag with
20+ the word "error" in the name.
21+ </callout-info >
22+
1823Example error response:
1924
2025``` json
Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ export class DB {
155155 // Tag Methods
156156 async createTag ( tag : NewTag ) {
157157 const validatedTag = newTagSchema . parse ( tag )
158+ if ( validatedTag . name . toLocaleLowerCase ( ) . includes ( 'error' ) ) {
159+ throw new Error ( 'Tag name cannot include the word "error"' )
160+ }
158161 const stmt = this . #db. prepare ( sql `
159162 INSERT INTO tags (name, description)
160163 VALUES (?, ?)
Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ export class DB {
155155 // Tag Methods
156156 async createTag ( tag : NewTag ) {
157157 const validatedTag = newTagSchema . parse ( tag )
158+ if ( validatedTag . name . toLocaleLowerCase ( ) . includes ( 'error' ) ) {
159+ throw new Error ( 'Tag name cannot include the word "error"' )
160+ }
158161 const stmt = this . #db. prepare ( sql `
159162 INSERT INTO tags (name, description)
160163 VALUES (?, ?)
You can’t perform that action at this time.
0 commit comments