How to use the @sentry/utils.isInstanceOf function in @sentry/utils

To help you get started, we’ve selected a few @sentry/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getsentry / sentry-javascript / packages / browser / src / integrations / linkederrors.ts View on Github external
private _walkErrorTree(error: ExtendedError, key: string, stack: Exception[] = []): Exception[] {
    if (!isInstanceOf(error[key], Error) || stack.length + 1 >= this._limit) {
      return stack;
    }
    const stacktrace = computeStackTrace(error[key]);
    const exception = exceptionFromStacktrace(stacktrace);
    return this._walkErrorTree(error[key], key, [exception, ...stack]);
  }
}
github getsentry / sentry-javascript / packages / node / src / integrations / linkederrors.ts View on Github external
public walkErrorTree(error: ExtendedError, key: string, stack: Exception[] = []): PromiseLike {
    if (!isInstanceOf(error[key], Error) || stack.length + 1 >= this._limit) {
      return SyncPromise.resolve(stack);
    }
    return new SyncPromise((resolve, reject) => {
      getExceptionFromError(error[key])
        .then((exception: Exception) => {
          this.walkErrorTree(error[key], key, [exception, ...stack])
            .then(resolve)
            .then(null, () => {
              reject();
            });
        })
        .then(null, () => {
          reject();
        });
    });
  }
github getsentry / sentry-javascript / packages / apm / src / hubextensions.ts View on Github external
function isSpanInstance(span: unknown): span is Span {
  return isInstanceOf(span, Span);
}
github getsentry / sentry-javascript / packages / node / src / integrations / linkederrors.ts View on Github external
public handler(event: Event, hint?: EventHint): PromiseLike {
    if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
      return SyncPromise.resolve(event);
    }

    return new SyncPromise(resolve => {
      this.walkErrorTree(hint.originalException as Error, this._key)
        .then((linkedErrors: Exception[]) => {
          if (event && event.exception && event.exception.values) {
            event.exception.values = [...linkedErrors, ...event.exception.values];
          }
          resolve(event);
        })
        .then(null, () => {
          resolve(event);
        });
    });
  }
github getsentry / sentry-javascript / packages / browser / src / integrations / linkederrors.ts View on Github external
private _handler(event: Event, hint?: EventHint): Event | null {
    if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
      return event;
    }
    const linkedErrors = this._walkErrorTree(hint.originalException as ExtendedError, this._key);
    event.exception.values = [...linkedErrors, ...event.exception.values];
    return event;
  }
github getsentry / sentry-javascript / packages / apm / src / span.ts View on Github external
public constructor(spanContext?: SpanContext, hub?: Hub) {
    if (isInstanceOf(hub, Hub)) {
      this._hub = hub as Hub;
    }

    if (!spanContext) {
      return this;
    }

    if (spanContext.traceId) {
      this._traceId = spanContext.traceId;
    }
    if (spanContext.spanId) {
      this._spanId = spanContext.spanId;
    }
    if (spanContext.parentSpanId) {
      this._parentSpanId = spanContext.parentSpanId;
    }