@metamask-previews/error-reporting-service 3.0.0-preview-102c9cee → 3.0.0-preview-de995bed
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.
- package/CHANGELOG.md +0 -6
- package/README.md +0 -5
- package/dist/error-reporting-service.cjs +0 -5
- package/dist/error-reporting-service.cjs.map +1 -1
- package/dist/error-reporting-service.d.cts +0 -8
- package/dist/error-reporting-service.d.cts.map +1 -1
- package/dist/error-reporting-service.d.mts +0 -8
- package/dist/error-reporting-service.d.mts.map +1 -1
- package/dist/error-reporting-service.mjs +0 -5
- package/dist/error-reporting-service.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Changed
|
|
11
|
-
|
|
12
|
-
- Add deprecation notice ([#7427](https://github.com/MetaMask/core/pull/7427))
|
|
13
|
-
- This package is deprecated, and can be replaced with the
|
|
14
|
-
`Messenger.captureException` method from `@metamask/messenger`.
|
|
15
|
-
|
|
16
10
|
## [3.0.0]
|
|
17
11
|
|
|
18
12
|
### Changed
|
package/README.md
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
# `@metamask/error-reporting-service`
|
|
2
2
|
|
|
3
|
-
> [!WARNING]
|
|
4
|
-
> This package is deprecated. To report errors, please use
|
|
5
|
-
> [`Messenger.captureException`](https://github.com/MetaMask/core/blob/8b3ad82c35d9d75c9a5096d847e7e8651e29cc5e/packages/messenger/src/Messenger.ts#L258-L263)
|
|
6
|
-
> instead.
|
|
7
|
-
|
|
8
3
|
Reports errors to an external app such as Sentry but in an agnostic fashion.
|
|
9
4
|
|
|
10
5
|
## Installation
|
|
@@ -104,9 +104,6 @@ exports.ErrorReportingService = void 0;
|
|
|
104
104
|
* // Now this will report an error without throwing it.
|
|
105
105
|
* exampleController.doSomething();
|
|
106
106
|
* ```
|
|
107
|
-
*
|
|
108
|
-
* @deprecated This service is deprecated and will be removed in a future
|
|
109
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
110
107
|
*/
|
|
111
108
|
class ErrorReportingService {
|
|
112
109
|
/**
|
|
@@ -131,8 +128,6 @@ class ErrorReportingService {
|
|
|
131
128
|
* Reports the given error to an external location.
|
|
132
129
|
*
|
|
133
130
|
* @param error - The error to report.
|
|
134
|
-
* @deprecated This function is deprecated and will be removed in a future
|
|
135
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
136
131
|
*/
|
|
137
132
|
captureException(error) {
|
|
138
133
|
__classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").call(this, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-reporting-service.cjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"error-reporting-service.cjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAa,qBAAqB;IAShC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAjBzE,SAAI,GAA4B,uBAAgC,CAAC;QAEjE,UAAK,GAAG,IAAI,CAAC;QAEJ,0DAAoE;QAEpE,mDAA2C;QAYlD,uBAAA,IAAI,oCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,2CAAqB,gBAAgB,MAAA,CAAC;QAE1C,uBAAA,IAAI,wCAAW,CAAC,qBAAqB,CACnC,wCAAwC,EACxC,uBAAA,IAAI,+CAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,KAAY;QAC3B,uBAAA,IAAI,+CAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AApCD,sDAoCC","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\n/**\n * The action which can be used to report an error.\n */\nexport type ErrorReportingServiceCaptureExceptionAction = {\n type: 'ErrorReportingService:captureException';\n handler: ErrorReportingService['captureException'];\n};\n\n/**\n * All actions that {@link ErrorReportingService} registers so that other\n * modules can call them.\n */\nexport type ErrorReportingServiceActions =\n ErrorReportingServiceCaptureExceptionAction;\n\n/**\n * All events that {@link ErrorReportingService} publishes so that other modules\n * can subscribe to them.\n */\nexport type ErrorReportingServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link ErrorReportingService}\n * calls.\n */\ntype AllowedActions = never;\n\n/**\n * All events published by other modules that {@link ErrorReportingService}\n * subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events that\n * {@link ErrorReportingService} needs to access.\n */\nexport type ErrorReportingServiceMessenger = Messenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: ErrorReportingService['captureException'];\n messenger: ErrorReportingServiceMessenger;\n};\n\n/**\n * `ErrorReportingService` is designed to log an error to an error reporting app\n * such as Sentry, but in an agnostic fashion.\n *\n * @example\n *\n * In this example, we have a controller, and something bad happens, but we want\n * to report an error instead of throwing it.\n *\n * ``` ts\n * // === Controller file ===\n *\n * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';\n *\n * // Define the messenger type for the controller.\n * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;\n * type ExampleControllerMessenger = Messenger<\n * 'ExampleController',\n * AllowedActions,\n * never,\n * >;\n *\n * // Define the controller.\n * class ExampleController extends BaseController<\n * 'ExampleController',\n * ExampleControllerState,\n * ExampleControllerMessenger\n * > {\n * doSomething() {\n * // Imagine that we do something that produces an error and we want to\n * // report the error.\n * this.messenger.call(\n * 'ErrorReportingService:captureException',\n * new Error('Something went wrong'),\n * );\n * }\n * }\n *\n * // === Initialization file ===\n *\n * import { captureException } from '@sentry/browser';\n * import { ErrorReportingService } from '@metamask/error-reporting-service';\n * import { ExampleController } from './example-controller';\n *\n * type RootMessenger = Messenger<\n * 'Root',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>\n * >;\n *\n * // Create a root messenger.\n * const rootMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the root messenger.\n * const errorReportingServiceMessenger = new Messenger<\n * 'ErrorReportingService',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ErrorReportingService',\n * parent: rootMessenger,\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = new Messenger<\n * 'ExampleController',\n * MessengerActions<ExampleControllerMessenger>,\n * MessengerEvents<ExampleControllerMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ExampleController',\n * parent: rootMessenger,\n * });\n * rootMessenger.delegate({\n * messenger: exampleControllerMessenger,\n * actions: ['ErrorReportingService:captureException'],\n * });\n * const exampleController = new ExampleController({\n * messenger: exampleControllerMessenger,\n * });\n *\n * // === Somewhere else ===\n *\n * // Now this will report an error without throwing it.\n * exampleController.doSomething();\n * ```\n */\nexport class ErrorReportingService {\n name: 'ErrorReportingService' = 'ErrorReportingService' as const;\n\n state = null;\n\n readonly #captureException: ErrorReportingServiceOptions['captureException'];\n\n readonly #messenger: ErrorReportingServiceMessenger;\n\n /**\n * Constructs a new ErrorReportingService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * ErrorReportingService.\n * @param options.captureException - A function that stores the given error in\n * the error reporting service.\n */\n constructor({ messenger, captureException }: ErrorReportingServiceOptions) {\n this.#messenger = messenger;\n this.#captureException = captureException;\n\n this.#messenger.registerActionHandler(\n 'ErrorReportingService:captureException',\n this.#captureException.bind(this),\n );\n }\n\n /**\n * Reports the given error to an external location.\n *\n * @param error - The error to report.\n */\n captureException(error: Error): void {\n this.#captureException(error);\n }\n}\n"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { Messenger } from "@metamask/messenger";
|
|
2
2
|
/**
|
|
3
3
|
* The action which can be used to report an error.
|
|
4
|
-
*
|
|
5
|
-
* @deprecated This action is deprecated and will be removed in a future
|
|
6
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
7
4
|
*/
|
|
8
5
|
export type ErrorReportingServiceCaptureExceptionAction = {
|
|
9
6
|
type: 'ErrorReportingService:captureException';
|
|
@@ -132,9 +129,6 @@ type ErrorReportingServiceOptions = {
|
|
|
132
129
|
* // Now this will report an error without throwing it.
|
|
133
130
|
* exampleController.doSomething();
|
|
134
131
|
* ```
|
|
135
|
-
*
|
|
136
|
-
* @deprecated This service is deprecated and will be removed in a future
|
|
137
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
138
132
|
*/
|
|
139
133
|
export declare class ErrorReportingService {
|
|
140
134
|
#private;
|
|
@@ -154,8 +148,6 @@ export declare class ErrorReportingService {
|
|
|
154
148
|
* Reports the given error to an external location.
|
|
155
149
|
*
|
|
156
150
|
* @param error - The error to report.
|
|
157
|
-
* @deprecated This function is deprecated and will be removed in a future
|
|
158
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
159
151
|
*/
|
|
160
152
|
captureException(error: Error): void;
|
|
161
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-reporting-service.d.cts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD
|
|
1
|
+
{"version":3,"file":"error-reporting-service.d.cts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;GAEG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GACtC,2CAA2C,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,SAAS,CACpD,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC5D,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,qBAAa,qBAAqB;;IAChC,IAAI,EAAE,uBAAuB,CAAoC;IAEjE,KAAK,OAAQ;IAMb;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { Messenger } from "@metamask/messenger";
|
|
2
2
|
/**
|
|
3
3
|
* The action which can be used to report an error.
|
|
4
|
-
*
|
|
5
|
-
* @deprecated This action is deprecated and will be removed in a future
|
|
6
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
7
4
|
*/
|
|
8
5
|
export type ErrorReportingServiceCaptureExceptionAction = {
|
|
9
6
|
type: 'ErrorReportingService:captureException';
|
|
@@ -132,9 +129,6 @@ type ErrorReportingServiceOptions = {
|
|
|
132
129
|
* // Now this will report an error without throwing it.
|
|
133
130
|
* exampleController.doSomething();
|
|
134
131
|
* ```
|
|
135
|
-
*
|
|
136
|
-
* @deprecated This service is deprecated and will be removed in a future
|
|
137
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
138
132
|
*/
|
|
139
133
|
export declare class ErrorReportingService {
|
|
140
134
|
#private;
|
|
@@ -154,8 +148,6 @@ export declare class ErrorReportingService {
|
|
|
154
148
|
* Reports the given error to an external location.
|
|
155
149
|
*
|
|
156
150
|
* @param error - The error to report.
|
|
157
|
-
* @deprecated This function is deprecated and will be removed in a future
|
|
158
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
159
151
|
*/
|
|
160
152
|
captureException(error: Error): void;
|
|
161
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-reporting-service.d.mts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD
|
|
1
|
+
{"version":3,"file":"error-reporting-service.d.mts","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;GAEG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GACtC,2CAA2C,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,SAAS,CACpD,uBAAuB,EACvB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAEF;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAClC,gBAAgB,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC5D,SAAS,EAAE,8BAA8B,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,qBAAa,qBAAqB;;IAChC,IAAI,EAAE,uBAAuB,CAAoC;IAEjE,KAAK,OAAQ;IAMb;;;;;;;;OAQG;gBACS,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,4BAA4B;IAUzE;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAGrC"}
|
|
@@ -101,9 +101,6 @@ var _ErrorReportingService_captureException, _ErrorReportingService_messenger;
|
|
|
101
101
|
* // Now this will report an error without throwing it.
|
|
102
102
|
* exampleController.doSomething();
|
|
103
103
|
* ```
|
|
104
|
-
*
|
|
105
|
-
* @deprecated This service is deprecated and will be removed in a future
|
|
106
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
107
104
|
*/
|
|
108
105
|
export class ErrorReportingService {
|
|
109
106
|
/**
|
|
@@ -128,8 +125,6 @@ export class ErrorReportingService {
|
|
|
128
125
|
* Reports the given error to an external location.
|
|
129
126
|
*
|
|
130
127
|
* @param error - The error to report.
|
|
131
|
-
* @deprecated This function is deprecated and will be removed in a future
|
|
132
|
-
* release. Please use `Messenger.captureException` directly instead.
|
|
133
128
|
*/
|
|
134
129
|
captureException(error) {
|
|
135
130
|
__classPrivateFieldGet(this, _ErrorReportingService_captureException, "f").call(this, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-reporting-service.mjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"error-reporting-service.mjs","sourceRoot":"","sources":["../src/error-reporting-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAM,OAAO,qBAAqB;IAShC;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAgC;QAjBzE,SAAI,GAA4B,uBAAgC,CAAC;QAEjE,UAAK,GAAG,IAAI,CAAC;QAEJ,0DAAoE;QAEpE,mDAA2C;QAYlD,uBAAA,IAAI,oCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,2CAAqB,gBAAgB,MAAA,CAAC;QAE1C,uBAAA,IAAI,wCAAW,CAAC,qBAAqB,CACnC,wCAAwC,EACxC,uBAAA,IAAI,+CAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,KAAY;QAC3B,uBAAA,IAAI,+CAAkB,MAAtB,IAAI,EAAmB,KAAK,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\n/**\n * The action which can be used to report an error.\n */\nexport type ErrorReportingServiceCaptureExceptionAction = {\n type: 'ErrorReportingService:captureException';\n handler: ErrorReportingService['captureException'];\n};\n\n/**\n * All actions that {@link ErrorReportingService} registers so that other\n * modules can call them.\n */\nexport type ErrorReportingServiceActions =\n ErrorReportingServiceCaptureExceptionAction;\n\n/**\n * All events that {@link ErrorReportingService} publishes so that other modules\n * can subscribe to them.\n */\nexport type ErrorReportingServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link ErrorReportingService}\n * calls.\n */\ntype AllowedActions = never;\n\n/**\n * All events published by other modules that {@link ErrorReportingService}\n * subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events that\n * {@link ErrorReportingService} needs to access.\n */\nexport type ErrorReportingServiceMessenger = Messenger<\n 'ErrorReportingService',\n ErrorReportingServiceActions | AllowedActions,\n ErrorReportingServiceEvents | AllowedEvents\n>;\n\n/**\n * The options that {@link ErrorReportingService} takes.\n */\ntype ErrorReportingServiceOptions = {\n captureException: ErrorReportingService['captureException'];\n messenger: ErrorReportingServiceMessenger;\n};\n\n/**\n * `ErrorReportingService` is designed to log an error to an error reporting app\n * such as Sentry, but in an agnostic fashion.\n *\n * @example\n *\n * In this example, we have a controller, and something bad happens, but we want\n * to report an error instead of throwing it.\n *\n * ``` ts\n * // === Controller file ===\n *\n * import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';\n *\n * // Define the messenger type for the controller.\n * type AllowedActions = ErrorReportingServiceCaptureExceptionAction;\n * type ExampleControllerMessenger = Messenger<\n * 'ExampleController',\n * AllowedActions,\n * never,\n * >;\n *\n * // Define the controller.\n * class ExampleController extends BaseController<\n * 'ExampleController',\n * ExampleControllerState,\n * ExampleControllerMessenger\n * > {\n * doSomething() {\n * // Imagine that we do something that produces an error and we want to\n * // report the error.\n * this.messenger.call(\n * 'ErrorReportingService:captureException',\n * new Error('Something went wrong'),\n * );\n * }\n * }\n *\n * // === Initialization file ===\n *\n * import { captureException } from '@sentry/browser';\n * import { ErrorReportingService } from '@metamask/error-reporting-service';\n * import { ExampleController } from './example-controller';\n *\n * type RootMessenger = Messenger<\n * 'Root',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>\n * >;\n *\n * // Create a root messenger.\n * const rootMessenger = new Messenger();\n *\n * // Register handler for the `ErrorReportingService:captureException`\n * // action in the root messenger.\n * const errorReportingServiceMessenger = new Messenger<\n * 'ErrorReportingService',\n * MessengerActions<ErrorReportingServiceMessenger>,\n * MessengerEvents<ErrorReportingServiceMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ErrorReportingService',\n * parent: rootMessenger,\n * });\n * const errorReportingService = new ErrorReportingService({\n * messenger: errorReportingServiceMessenger,\n * captureException,\n * });\n *\n * const exampleControllerMessenger = new Messenger<\n * 'ExampleController',\n * MessengerActions<ExampleControllerMessenger>,\n * MessengerEvents<ExampleControllerMessenger>,\n * RootMessenger\n * >({\n * namespace: 'ExampleController',\n * parent: rootMessenger,\n * });\n * rootMessenger.delegate({\n * messenger: exampleControllerMessenger,\n * actions: ['ErrorReportingService:captureException'],\n * });\n * const exampleController = new ExampleController({\n * messenger: exampleControllerMessenger,\n * });\n *\n * // === Somewhere else ===\n *\n * // Now this will report an error without throwing it.\n * exampleController.doSomething();\n * ```\n */\nexport class ErrorReportingService {\n name: 'ErrorReportingService' = 'ErrorReportingService' as const;\n\n state = null;\n\n readonly #captureException: ErrorReportingServiceOptions['captureException'];\n\n readonly #messenger: ErrorReportingServiceMessenger;\n\n /**\n * Constructs a new ErrorReportingService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * ErrorReportingService.\n * @param options.captureException - A function that stores the given error in\n * the error reporting service.\n */\n constructor({ messenger, captureException }: ErrorReportingServiceOptions) {\n this.#messenger = messenger;\n this.#captureException = captureException;\n\n this.#messenger.registerActionHandler(\n 'ErrorReportingService:captureException',\n this.#captureException.bind(this),\n );\n }\n\n /**\n * Reports the given error to an external location.\n *\n * @param error - The error to report.\n */\n captureException(error: Error): void {\n this.#captureException(error);\n }\n}\n"]}
|
package/package.json
CHANGED