Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
Class 'MonitoringError' incorrectly extends base class 'Error'

Im trying to extend the Error class with the following ( for monitoring with Sentry in React Native ) but get the following error.

Class 'MonitoringError' incorrectly extends base class 'Error'.
      Types of property 'name' are incompatible.
        Type 'string | boolean | CaptureContext | undefined' is not assignable to type 'string'.
          Type 'undefined' is not assignable to type 'string'.

With the following code

import { CaptureContext } from '@sentry/types';
import { ComponentType } from 'react';
import { FallbackProps } from 'react-error-boundary';
import { eventMonitoring } from './SentryCrashlyticsService';

export class MonitoringError extends Error {
  constructor(
    public message: string,
    public name?: string | CaptureContext | boolean,
    public captureContext?: CaptureContext | boolean,
  ) {
    super(message);
  }

  public capture: () => void = () => {
    let skipLogging = false as boolean | undefined;
    let ctx = this.captureContext;
    let name;

    if (this.name && typeof this.name === 'string') {
      name = this.name;
    } else if (this.name && typeof this.name === 'boolean') {
      skipLogging = name;
    } else if (name) {
      ctx = name as CaptureContext;
    }
    if (typeof this.captureContext === 'boolean' && !skipLogging) {
      skipLogging = true;
    }

    if (!skipLogging) {
      eventMonitoring.captureException(this, ctx as CaptureContext);
    }
  };
}

Whats the best way to extend, if possible.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!