cloudflare-next-intl 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import type { ErrorHandlingParams } from '../types/types';
|
|
2
2
|
import { type ReportErrorConfig } from './report_error';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* `reportError`,
|
|
4
|
+
* Builds a function that reports a client-originated error via
|
|
5
|
+
* `reportError`, meant to be re-exported directly from your OWN
|
|
6
|
+
* `"use server"` file so `config` (and anything it closes over — secrets,
|
|
6
7
|
* `Secrets.telegramBotToken`-style env reads inside your `onError`) never
|
|
7
|
-
* has to be imported into client-side code
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* has to be imported into client-side code:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // report_client_error.ts
|
|
12
|
+
* "use server";
|
|
13
|
+
* import createServerErrorAction from "cloudflare-next-intl/createServerErrorAction";
|
|
14
|
+
* import intlConfig from "./intl_config";
|
|
15
|
+
* export const reportClientError = createServerErrorAction(intlConfig);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* This function itself must NOT be called from a file marked `"use server"`
|
|
19
|
+
* — Next.js requires every top-level export of such a file to be an async
|
|
20
|
+
* function directly; a factory that returns one doesn't qualify. Put
|
|
21
|
+
* `"use server"` in your OWN file (as above), not in a file that calls
|
|
22
|
+
* `createServerErrorAction` and re-exports its result under a different
|
|
23
|
+
* name than a plain `const`.
|
|
11
24
|
*
|
|
12
25
|
* The error is stringified before crossing the client→server action
|
|
13
26
|
* boundary (Next.js server actions serialize arguments; an `Error` instance
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
"use server";
|
|
2
1
|
import reportError from './report_error';
|
|
3
2
|
import stringifyUnknown from './stringify_unknown';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* `reportError`,
|
|
4
|
+
* Builds a function that reports a client-originated error via
|
|
5
|
+
* `reportError`, meant to be re-exported directly from your OWN
|
|
6
|
+
* `"use server"` file so `config` (and anything it closes over — secrets,
|
|
7
7
|
* `Secrets.telegramBotToken`-style env reads inside your `onError`) never
|
|
8
|
-
* has to be imported into client-side code
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* has to be imported into client-side code:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // report_client_error.ts
|
|
12
|
+
* "use server";
|
|
13
|
+
* import createServerErrorAction from "cloudflare-next-intl/createServerErrorAction";
|
|
14
|
+
* import intlConfig from "./intl_config";
|
|
15
|
+
* export const reportClientError = createServerErrorAction(intlConfig);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* This function itself must NOT be called from a file marked `"use server"`
|
|
19
|
+
* — Next.js requires every top-level export of such a file to be an async
|
|
20
|
+
* function directly; a factory that returns one doesn't qualify. Put
|
|
21
|
+
* `"use server"` in your OWN file (as above), not in a file that calls
|
|
22
|
+
* `createServerErrorAction` and re-exports its result under a different
|
|
23
|
+
* name than a plain `const`.
|
|
12
24
|
*
|
|
13
25
|
* The error is stringified before crossing the client→server action
|
|
14
26
|
* boundary (Next.js server actions serialize arguments; an `Error` instance
|