admin-test.resolver.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { Args, Mutation, Resolver } from '@nestjs/graphql';
  2. import { Allow, Permission, UserInputError } from '@vendure/core';
  3. import { SentryService } from '../sentry.service';
  4. import { ErrorTestService } from './error-test.service';
  5. declare const a: number;
  6. @Resolver()
  7. export class SentryAdminTestResolver {
  8. constructor(private sentryService: SentryService, private errorTestService: ErrorTestService) {}
  9. @Allow(Permission.SuperAdmin)
  10. @Mutation()
  11. async createTestError(@Args() args: { errorType: string }) {
  12. switch (args.errorType) {
  13. case 'UNCAUGHT_ERROR':
  14. return a / 10;
  15. case 'THROWN_ERROR':
  16. throw new UserInputError('SentryPlugin Test Error');
  17. case 'CAPTURED_ERROR':
  18. this.sentryService.captureException(new Error('SentryPlugin Direct error'));
  19. return true;
  20. case 'CAPTURED_MESSAGE':
  21. this.sentryService.captureMessage('Captured message');
  22. return true;
  23. case 'DATABASE_ERROR':
  24. await this.errorTestService.createDatabaseError();
  25. return true;
  26. }
  27. }
  28. }