Skip to content

Commit 6eec71c

Browse files
committed
fix highlighting
Closes #63
1 parent 549c199 commit 6eec71c

File tree

1 file changed

+3
-2
lines changed
  • exercises/07.error-handling/02.problem.thrown-response

1 file changed

+3
-2
lines changed

exercises/07.error-handling/02.problem.thrown-response/README.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,24 @@ export async function requireUser(request: Request) {
112112
This is a great way to make nice utilities that make the regular application
113113
code much easier to write and read:
114114

115-
```tsx filename=app/routes/sandwiches.$sandwichId.tsx add=8,17 remove=9-12,18-21
115+
```tsx filename=app/routes/sandwiches.$sandwichId.tsx add=8,17 remove=9-13,18-22
116116
import { json, type DataFunctionArgs, type MetaFunction } from '@remix-run/node'
117117
import { invariantResponse, useIsSubmitting } from '#app/utils/misc.tsx'
118118
import { getUser } from '#app/utils/auth.server'
119119
import { requireUser } from '#app/utils/auth.server'
120120
import { getSandwich } from '#app/utils/sandwiches.server'
121121

122122
export async function loader({ request, params }: DataFunctionArgs) {
123+
const user = await requireUser(request)
123124
const user = await getUser(request)
124125
if (!user) {
125126
// this response will be handled by our error boundary
126127
throw new Response('Unauthorized', { status: 401 })
127128
}
128-
const user = await requireUser(request)
129129
// this invariant with throw an error which our error boundary will handle as well
130130
invariantResponse(params.sandwichId, 'sandwichId is required')
131131

132+
const sandwich = await requireSandwich(params.sandwichId)
132133
const sandwich = await getSandwich(params.sandwichId)
133134
if (!sandwich) {
134135
// this response will be handled by our error boundary

0 commit comments

Comments
 (0)