Skip to content

Commit a4226b8

Browse files
authored
fix(angular): Make SentryErrorHandler extensible and export it publicly (#3438)
1 parent 888275c commit a4226b8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/angular/src/errorhandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface ErrorHandlerOptions {
2222
*/
2323
@Injectable({ providedIn: 'root' })
2424
class SentryErrorHandler implements AngularErrorHandler {
25-
private readonly _options: ErrorHandlerOptions;
25+
protected readonly _options: ErrorHandlerOptions;
2626

2727
public constructor(options?: ErrorHandlerOptions) {
2828
this._options = {
@@ -55,7 +55,7 @@ class SentryErrorHandler implements AngularErrorHandler {
5555
/**
5656
* Used to pull a desired value that will be used to capture an event out of the raw value captured by ErrorHandler.
5757
*/
58-
private _extractError(error: unknown): unknown {
58+
protected _extractError(error: unknown): unknown {
5959
// Allow custom overrides of extracting function
6060
if (this._options.extractor) {
6161
const defaultExtractor = this._defaultExtractor.bind(this);
@@ -68,7 +68,7 @@ class SentryErrorHandler implements AngularErrorHandler {
6868
/**
6969
* Default implementation of error extraction that handles default error wrapping, HTTP responses, ErrorEvent and few other known cases.
7070
*/
71-
private _defaultExtractor(errorCandidate: unknown): unknown {
71+
protected _defaultExtractor(errorCandidate: unknown): unknown {
7272
let error = errorCandidate;
7373

7474
// Try to unwrap zone.js error.
@@ -115,4 +115,4 @@ function createErrorHandler(config?: ErrorHandlerOptions): SentryErrorHandler {
115115
return new SentryErrorHandler(config);
116116
}
117117

118-
export { createErrorHandler };
118+
export { createErrorHandler, SentryErrorHandler };

packages/angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export * from '@sentry/browser';
22

33
export { init } from './sdk';
4-
export { createErrorHandler, ErrorHandlerOptions } from './errorhandler';
4+
export { createErrorHandler, ErrorHandlerOptions, SentryErrorHandler } from './errorhandler';
55
export {
66
getActiveTransaction,
77
// TODO `instrumentAngularRouting` is just an alias for `routingInstrumentation`; deprecate the latter at some point

0 commit comments

Comments
 (0)