Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow handled errors to be processed #2059

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,18 @@ describe('ErrorHandler', () => {
expect(defaultLogger.error).toHaveBeenCalledTimes(0);
});

it('should skip handled errors if they are not originated from the sdk', () => {
it('should not skip handled errors even if they are not originated from the sdk', () => {
// Enable error reporting
state.reporting.isErrorReportingEnabled.value = true;

// For this error, the stacktrace would not contain the sdk file names
errorHandlerInstance.onError(new Error('dummy error'));

// It should not be logged to the console
expect(defaultLogger.error).toHaveBeenCalledTimes(0);
// It should be reported to the metrics service
expect(defaultHttpClient.getAsyncData).toHaveBeenCalledTimes(1);

// It should be logged to the console
expect(defaultLogger.error).toHaveBeenCalledTimes(1);
});

it('should not log unhandled errors to the console', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ class ErrorHandler implements IErrorHandler {
const isSdkDispatched = stacktrace.includes(MANUAL_ERROR_IDENTIFIER);

// Filter errors that are not originated in the SDK.
// In case of NPM installations, the errors from the SDK cannot be identified
// In case of NPM installations, the unhandled errors from the SDK cannot be identified
// and will NOT be reported unless they occur in plugins or integrations.
if (!isSdkDispatched && !isSDKError(bsException)) {
if (
!isSdkDispatched &&
!isSDKError(bsException) &&
errorType !== ErrorType.HANDLEDEXCEPTION
) {
return;
}

Expand Down