Files
outline/server/errors.test.ts
T
Copilot 9858d160d5 Separate user input errors from internal errors for Sentry reporting (#11308)
* Initial plan

* Add explicit error categorization with isSentryReported property

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Rename isSentryReported to isReportable

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Update Discord plugin errors to use isReportable

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>
2026-01-30 05:55:28 -05:00

61 lines
2.8 KiB
TypeScript

import * as errors from "./errors";
describe("errors", () => {
describe("InternalError", () => {
it("should be marked for Sentry reporting", () => {
const error = errors.InternalError();
expect(error.isReportable).toBe(true);
});
it("should have status 500", () => {
const error = errors.InternalError();
expect(error.status).toBe(500);
});
});
describe("User input errors", () => {
const userInputErrors = [
{ name: "AuthenticationError", fn: errors.AuthenticationError },
{ name: "InvalidAuthenticationError", fn: errors.InvalidAuthenticationError },
{ name: "AuthorizationError", fn: errors.AuthorizationError },
{ name: "CSRFError", fn: errors.CSRFError },
{ name: "RateLimitExceededError", fn: errors.RateLimitExceededError },
{ name: "InviteRequiredError", fn: errors.InviteRequiredError },
{ name: "DomainNotAllowedError", fn: errors.DomainNotAllowedError },
{ name: "AdminRequiredError", fn: errors.AdminRequiredError },
{ name: "InvalidRequestError", fn: errors.InvalidRequestError },
{ name: "PaymentRequiredError", fn: errors.PaymentRequiredError },
{ name: "NotFoundError", fn: errors.NotFoundError },
{ name: "ParamRequiredError", fn: errors.ParamRequiredError },
{ name: "ValidationError", fn: errors.ValidationError },
{ name: "IncorrectEditionError", fn: errors.IncorrectEditionError },
{ name: "EditorUpdateError", fn: errors.EditorUpdateError },
{ name: "FileImportError", fn: errors.FileImportError },
{ name: "OAuthStateMismatchError", fn: errors.OAuthStateMismatchError },
{ name: "TeamPendingDeletionError", fn: errors.TeamPendingDeletionError },
{ name: "EmailAuthenticationRequiredError", fn: errors.EmailAuthenticationRequiredError },
{ name: "MicrosoftGraphError", fn: errors.MicrosoftGraphError },
{ name: "TeamDomainRequiredError", fn: errors.TeamDomainRequiredError },
{ name: "GmailAccountCreationError", fn: errors.GmailAccountCreationError },
{ name: "OIDCMalformedUserInfoError", fn: errors.OIDCMalformedUserInfoError },
{ name: "AuthenticationProviderDisabledError", fn: errors.AuthenticationProviderDisabledError },
{ name: "UnprocessableEntityError", fn: errors.UnprocessableEntityError },
{ name: "ClientClosedRequestError", fn: errors.ClientClosedRequestError },
];
userInputErrors.forEach(({ name, fn }) => {
it(`${name} should not be marked for Sentry reporting`, () => {
const error = fn();
expect(error.isReportable).toBe(false);
});
});
});
describe("UserSuspendedError", () => {
it("should not be marked for Sentry reporting", () => {
const error = errors.UserSuspendedError({ adminEmail: "test@example.com" });
expect(error.isReportable).toBe(false);
});
});
});