Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis committed Feb 29, 2024
1 parent 99ddba2 commit f0daf7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/houdini-react/src/runtime/routing/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function usePageData({
const observer = client.observe({ artifact, cache })

let resolve: () => void = () => {}
let reject: () => void = () => {}
let reject: (message: string) => void = () => {}
const promise = new Promise<void>((res, rej) => {
resolve = res
reject = rej
Expand All @@ -192,6 +192,13 @@ function usePageData({
})
.then(() => {
data_cache.set(id, observer)

// if there is an error, we need to reject the promise
if (observer.state.errors && observer.state.errors.length > 0) {
reject(observer.state.errors.map((e) => e.message).join('\n'))
return
}

console.log('resolving', observer.state)
// if we are building up a stream (on the server), we want to add something
// to the client that resolves the pending request with the
Expand Down

0 comments on commit f0daf7a

Please sign in to comment.