Skip to content

Commit

Permalink
better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhsuresh committed Nov 3, 2022
1 parent e5d115e commit 75922cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
23 changes: 16 additions & 7 deletions packages/blitz-rpc/src/data-client/react-query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
UseMutationOptions,
UseMutationResult,
} from "@tanstack/react-query"
import {isServer, FirstParam, PromiseReturnType, AsyncFunc} from "blitz"
import {isServer, FirstParam, PromiseReturnType, AsyncFunc, log} from "blitz"

import {
emptyQueryFn,
Expand Down Expand Up @@ -88,9 +88,12 @@ export function useQuery<
useSession = mod.useSession
}, console.error)
} catch (e: any) {
if (e.code !== "MODULE_NOT_FOUND") {
throw e
if (e.code === "MODULE_NOT_FOUND") {
log.error(
"Blitz Auth is enabled but @blitzjs/auth is not installed. Please check if @blitzjs/auth is in your dependencies",
)
}
throw e
}
}
const session = useSession({suspense})
Expand Down Expand Up @@ -184,9 +187,12 @@ export function usePaginatedQuery<
useSession = mod.useSession
}, console.error)
} catch (e: any) {
if (e.code !== "MODULE_NOT_FOUND") {
throw e
if (e.code === "MODULE_NOT_FOUND") {
log.error(
"Blitz Auth is enabled but @blitzjs/auth is not installed. Please check if @blitzjs/auth is in your dependencies",
)
}
throw e
}
}
const session = useSession({suspense})
Expand Down Expand Up @@ -290,9 +296,12 @@ export function useInfiniteQuery<
useSession = mod.useSession
}, console.error)
} catch (e: any) {
if (e.code !== "MODULE_NOT_FOUND") {
throw e
if (e.code === "MODULE_NOT_FOUND") {
log.error(
"Blitz Auth is enabled but @blitzjs/auth is not installed. Please check if @blitzjs/auth is in your dependencies",
)
}
throw e
}
}
const session = useSession({suspense})
Expand Down
9 changes: 6 additions & 3 deletions packages/blitz-rpc/src/data-client/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {normalizePathTrailingSlash} from "next/dist/client/normalize-trailing-sl
import {addBasePath} from "next/dist/client/add-base-path"
import {deserialize, serialize} from "superjson"
import {SuperJSONResult} from "superjson/dist/types"
import {CSRFTokenMismatchError, isServer} from "blitz"
import {CSRFTokenMismatchError, isServer, log} from "blitz"
import {getQueryKeyFromUrlAndParams, getQueryClient} from "./react-query-utils"
import {stringify} from "superjson"

Expand Down Expand Up @@ -156,9 +156,12 @@ export function __internal_buildRpcClient({
throw err
}
} catch (e: any) {
if (e.code !== "MODULE_NOT_FOUND") {
throw e
if (e.code === "MODULE_NOT_FOUND") {
log.error(
"Blitz Auth is enabled but @blitzjs/auth is not installed. Please check if @blitzjs/auth is in your dependencies",
)
}
throw e
}
}

Expand Down

0 comments on commit 75922cb

Please sign in to comment.