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

🤖 Enhance Error Generation for Sentry Monitoring #620

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
17 changes: 12 additions & 5 deletions next/src/utils/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ if (typeof window !== 'undefined') {
history = createBrowserHistory();
}

// ERRORS
// Demonstration errors for Sentry monitoring
// Each function below intentionally creates a specific type of error for testing purposes

const notAFunctionError = () => {
const someArray = [{ func: function () {} }];
someArray[1].func();
// Intentionally create a TypeError by attempting to call a method on undefined
// This provides a clearer and more intentional way to generate a TypeError
const obj = undefined;
obj.nonExistentMethod();
};
const referenceError = () => {
throw new ReferenceError('undefinedVariable is not defined');
Expand All @@ -35,7 +39,10 @@ const throwErrorNumber = (i) => {
};

// if n is 0.2 then this will return false 20% of the time
var probability = function (n) {
// Ensure i is a valid number and handle potential undefined/null cases
// This prevents unintended errors while preserving intended demo errors
const errorIndex = typeof i === 'number' ? Math.abs(i) : 0;
randomErrors[errorIndex % randomErrors.length]();
return !!n && Math.random() <= n;
};

Expand Down Expand Up @@ -65,4 +72,4 @@ class UnhandledException extends Error {
}
}

export { crasher, UnhandledException };
export { crasher, UnhandledException };
Loading