You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/skills/next-v16/error-handling.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Error Handling
2
2
3
-
Handle errors in Next.js with **Sentry reporting** (`@repo/sentry/*`) and **structured logging** (`@repo/utils/logger/server` or `@repo/utils/logger/client`).
3
+
Handle errors in Next.js with the **`@repo/error` package** (Sentry-backed) and **structured logging** (`@repo/utils/logger/server` or `@repo/utils/logger/client`).
Copy file name to clipboardExpand all lines: apps/docu/content/docs/architecture/error-handling.mdx
+31-31Lines changed: 31 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
2
title: "Error Handling"
3
-
description: "Error handling with Sentry integration and app-level error catalogs."
3
+
description: "Error handling with error reporting and app-level error catalogs."
4
4
---
5
5
6
-
Complete guide for error handling across the monorepo: **`@repo/sentry`** for reporting to Sentry, **`@repo/utils/error`** for message extraction, and **app-level catalogs** for safe API responses.
6
+
Complete guide for error handling across the monorepo: **`@repo/error`** for error reporting and message extraction, and **app-level catalogs** for safe API responses.
7
7
8
8
## Overview
9
9
10
-
-**`@repo/sentry`** – `captureError(options)` sends errors to Sentry (void; does not return a catalog). Use platform subpaths: `node`, `nextjs`, `browser`, `react`.
11
-
-**`@repo/utils/error`** – `getErrorMessage(error)` and related utilities for type-safe message extraction.
12
-
-**Sentry initialization** – Not in `@repo/sentry`. Initialize per your platform’s [Sentry docs](https://docs.sentry.io/platforms/) (Node, Next.js, Browser).
10
+
-**`@repo/error`** – `captureError(options)` sends errors to the reporting backend (void; does not return a catalog). Use platform subpaths: `node`, `nextjs`, `browser`, `react`.
11
+
-**`@repo/error`** – `getErrorMessage(error)` and related utilities for type-safe message extraction (base export or `@repo/error/nextjs`).
12
+
-**Initialization** – Use `initErrorReporting` from `@repo/error/node` or `@repo/error/nextjs`. [GlitchTip](https://glitchtip.com/sdkdocs/javascript/) is recommended; Sentry also works (same DSN format).
13
13
-**Error catalogs and safe responses** – Implemented in each app (e.g. Fastify’s `apps/fastify/src/lib/catalogs/` with `getError`, `mapHttpStatusToErrorCode`). Apps build the safe `{ code, message }` response themselves.
14
14
15
15
**Key principles:**
@@ -23,10 +23,10 @@ Complete guide for error handling across the monorepo: **`@repo/sentry`** for re
23
23
24
24
```typescript
25
25
// For Next.js apps
26
-
import { captureError } from'@repo/sentry/nextjs'
26
+
import { captureError } from'@repo/error/nextjs'
27
27
28
28
// For Node.js/Fastify apps
29
-
// import { captureError } from '@repo/sentry/node'
29
+
// import { captureError } from '@repo/error/node'
Error catalogs and safe responses are implemented **per app**, not in `@repo/sentry`. For example, the Fastify app defines catalogs in `apps/fastify/src/lib/catalogs/` (e.g. `server.ts`, `client.ts`, `common.ts`) and exposes `getError(code)`, `mapHttpStatusToErrorCode(statusCode)`. The error handler calls `captureError` from `@repo/sentry/node` then builds the response using the app’s `getError`.
99
+
Error catalogs and safe responses are implemented **per app**, not in `@repo/error`. For example, the Fastify app defines catalogs in `apps/fastify/src/lib/catalogs/` (e.g. `server.ts`, `client.ts`, `common.ts`) and exposes `getError(code)`, `mapHttpStatusToErrorCode(statusCode)`. The error handler calls `captureError` from `@repo/error/node` then builds the response using the app’s `getError`.
100
100
101
101
**Adding new error codes:** Add them to your app’s catalog (e.g. `apps/fastify/src/lib/catalogs/`), then use `getError(yourCode)` when building responses. Use `UPPER_SNAKE_CASE` (e.g. `NETWORK_ERROR`, `USER_NOT_FOUND`).
102
102
@@ -121,11 +121,11 @@ Error catalogs and safe responses are implemented **per app**, not in `@repo/sen
121
121
122
122
#### Global Error Handler Plugin
123
123
124
-
Use `captureError` from `@repo/sentry/node` (void); build the response from the app’s catalog (`getError`, `mapHttpStatusToErrorCode` from `apps/fastify/src/lib/catalogs/`):
124
+
Use `captureError` from `@repo/error/node` (void); build the response from the app’s catalog (`getError`, `mapHttpStatusToErrorCode` from `apps/fastify/src/lib/catalogs/`):
exportdefaultfunction RootLayout({ children }: { children:React.ReactNode }) {
165
165
return (
@@ -170,13 +170,13 @@ export default function RootLayout({ children }: { children: React.ReactNode })
170
170
}
171
171
```
172
172
173
-
**Custom implementation:** Use `captureError` from `@repo/sentry/nextjs` in `onError`; it returns void. Show user-facing message via your fallback (e.g. `getErrorMessage(error)` from `@repo/utils/error`).
173
+
**Custom implementation:** Use `captureError` from `@repo/error/nextjs` in `onError`; it returns void. Show user-facing message via your fallback (e.g. `getErrorMessage(error)` from `@repo/error/nextjs`).
@@ -255,7 +255,7 @@ export async function serverAction() {
255
255
256
256
```typescript
257
257
'use server'
258
-
import { captureError } from'@repo/sentry/nextjs'
258
+
import { captureError } from'@repo/error/nextjs'
259
259
260
260
exportasyncfunction serverAction() {
261
261
try {
@@ -267,16 +267,16 @@ export async function serverAction() {
267
267
}
268
268
```
269
269
270
-
**Initialization:** Sentry is not initialized by `@repo/sentry`. Use [Sentry’s Next.js setup](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/) in `next.config`, `instrumentation.ts`, etc.
270
+
**Initialization:** Sentry is not initialized by `@repo/error`. Use [Sentry’s Next.js setup](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/) in `next.config`, `instrumentation.ts`, etc.
Sends the error to Sentry asynchronously. Does not return a catalog; each app builds its own response.
277
277
278
278
```typescript
279
-
import { captureError } from'@repo/sentry/nextjs'// or /node, /browser
279
+
import { captureError } from'@repo/error/nextjs'// or /node, /browser
280
280
281
281
captureError({
282
282
error: unknown, // Converted to Error if needed; full stack sent to Sentry
@@ -290,27 +290,27 @@ captureError({
290
290
})
291
291
```
292
292
293
-
See [packages/sentry/README.md](https://github.com/blockmatic/basilic/blob/main/packages/sentry/README.md) for full options. **Serverless:** Consider `Sentry.flush()` before function exit if the process terminates quickly.
293
+
See [@repo/error](https://github.com/blockmatic/basilic/blob/main/packages/error/README.md) for full options. **Serverless:** Consider `Sentry.flush()` before function exit if the process terminates quickly.
These live in each app (e.g. Fastify’s `apps/fastify/src/lib/catalogs/mapper.ts`). `mapHttpStatusToErrorCode(statusCode)` maps HTTP status to a catalog code; `getError(code)` returns `{ code, message }` for the response. Not part of `@repo/sentry`.
305
+
These live in each app (e.g. Fastify’s `apps/fastify/src/lib/catalogs/mapper.ts`). `mapHttpStatusToErrorCode(statusCode)` maps HTTP status to a catalog code; `getError(code)` returns `{ code, message }` for the response. Not part of `@repo/error`.
Copy file name to clipboardExpand all lines: apps/docu/content/docs/architecture/logging.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,10 +215,10 @@ try {
215
215
}
216
216
```
217
217
218
-
**5. Integration with `@repo/sentry`** - When using `captureError` in Fastify, pass `request.log` to use Fastify's native logger. The catalog and response are built in the app (e.g. from `apps/fastify/src/lib/catalogs/`):
218
+
**5. Integration with `@repo/error`** - When using `captureError` in Fastify, pass `request.log` to use Fastify's native logger. The catalog and response are built in the app (e.g. from `apps/fastify/src/lib/catalogs/`):
0 commit comments