Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
linkedErrors integrations
Creato
5 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
16 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
78 linee
Copia tutti
45 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
98 linee
Copia tutti
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types';
import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types';
Copia
Copiato
Copia
Copiato
import { isInstanceOf
} from '@sentry/utils';
import { isInstanceOf
, SyncPromise
} from '@sentry/utils';
Copia
Copiato
Copia
Copiato
import {
exceptionFromStacktrace
} from '../parsers';
import {
getExceptionFromError
} from '../parsers';
import { computeStackTrace } from '../tracekit';
const DEFAULT_KEY = 'cause';
const DEFAULT_KEY = 'cause';
const DEFAULT_LIMIT = 5;
const DEFAULT_LIMIT = 5;
/** Adds SDK info to an event. */
/** Adds SDK info to an event. */
export class LinkedErrors implements Integration {
export class LinkedErrors implements Integration {
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
public static id: string = 'LinkedErrors';
public static id: string = 'LinkedErrors';
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
public readonly name: string = LinkedErrors.id;
public readonly name: string = LinkedErrors.id;
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
private readonly _key: string;
private readonly _key: string;
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
private readonly _limit: number;
private readonly _limit: number;
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
public constructor(options: { key?: string; limit?: number } = {}) {
public constructor(options: { key?: string; limit?: number } = {}) {
this._key = options.key || DEFAULT_KEY;
this._key = options.key || DEFAULT_KEY;
this._limit = options.limit || DEFAULT_LIMIT;
this._limit = options.limit || DEFAULT_LIMIT;
}
}
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
public setupOnce(): void {
public setupOnce(): void {
addGlobalEventProcessor((event: Event, hint?: EventHint) => {
addGlobalEventProcessor((event: Event, hint?: EventHint) => {
const self = getCurrentHub().getIntegration(LinkedErrors);
const self = getCurrentHub().getIntegration(LinkedErrors);
if (self) {
if (self) {
Copia
Copiato
Copia
Copiato
return
self._
handler(event, hint)
;
const handler = self._handler && self._handler.bind(self);
return
typeof handler === 'function' ?
handler(event, hint)
: event
;
}
}
return event;
return event;
});
});
}
}
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
Copia
Copiato
Copia
Copiato
private _handler(event: Event, hint?: EventHint):
Event
| null
{
private _handler(event: Event, hint?: EventHint):
PromiseLike<
Event
>
{
if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
Copia
Copiato
Copia
Copiato
return
event
;
return
SyncPromise.resolve(
event
)
;
}
}
Copia
Copiato
Copia
Copiato
const linkedErrors =
this._walkErrorTree(hint.originalException as
ExtendedError
, this._key)
;
event.exception.values = [...linkedErrors, ...event.exception.values];
return new SyncPromise<Event>(resolve => {
return event;
void
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);
});
});
}
}
/**
/**
* @inheritDoc
* @inheritDoc
*/
*/
Copia
Copiato
Copia
Copiato
private _walkErrorTree(error: ExtendedError, key: string, stack: Exception[] = []):
Exception[]
{
private _walkErrorTree(error: ExtendedError, key: string, stack: Exception[] = []):
PromiseLike<
Exception[]
>
{
if (!isInstanceOf(error[key], Error) || stack.length + 1 >= this._limit) {
if (!isInstanceOf(error[key], Error) || stack.length + 1 >= this._limit) {
Copia
Copiato
Copia
Copiato
return
stack
;
return
SyncPromise.resolve(
stack
)
;
}
}
Copia
Copiato
Copia
Copiato
const stacktrace = computeStackTrace
(error[key])
;
return new SyncPromise<Exception[]>((resolve, reject) => {
const
exception
= exceptionFromStacktrace(stacktrace);
void getExceptionFromError
(error[key])
return
this._walkErrorTree(error[key], key, [exception, ...stack]
);
.then((
exception
: Exception) => {
void
this._walkErrorTree(error[key], key, [exception, ...stack]
)
.then(resolve)
.then(null, () => {
reject();
});
})
.then(null, () => {
reject();
});
});
}
}
}
}
Diff salvati
Testo originale
Apri file
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core'; import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types'; import { isInstanceOf } from '@sentry/utils'; import { exceptionFromStacktrace } from '../parsers'; import { computeStackTrace } from '../tracekit'; const DEFAULT_KEY = 'cause'; const DEFAULT_LIMIT = 5; /** Adds SDK info to an event. */ export class LinkedErrors implements Integration { /** * @inheritDoc */ public static id: string = 'LinkedErrors'; /** * @inheritDoc */ public readonly name: string = LinkedErrors.id; /** * @inheritDoc */ private readonly _key: string; /** * @inheritDoc */ private readonly _limit: number; /** * @inheritDoc */ public constructor(options: { key?: string; limit?: number } = {}) { this._key = options.key || DEFAULT_KEY; this._limit = options.limit || DEFAULT_LIMIT; } /** * @inheritDoc */ public setupOnce(): void { addGlobalEventProcessor((event: Event, hint?: EventHint) => { const self = getCurrentHub().getIntegration(LinkedErrors); if (self) { return self._handler(event, hint); } return event; }); } /** * @inheritDoc */ 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; } /** * @inheritDoc */ 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]); } }
Testo modificato
Apri file
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core'; import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types'; import { isInstanceOf, SyncPromise } from '@sentry/utils'; import { getExceptionFromError } from '../parsers'; const DEFAULT_KEY = 'cause'; const DEFAULT_LIMIT = 5; /** Adds SDK info to an event. */ export class LinkedErrors implements Integration { /** * @inheritDoc */ public static id: string = 'LinkedErrors'; /** * @inheritDoc */ public readonly name: string = LinkedErrors.id; /** * @inheritDoc */ private readonly _key: string; /** * @inheritDoc */ private readonly _limit: number; /** * @inheritDoc */ public constructor(options: { key?: string; limit?: number } = {}) { this._key = options.key || DEFAULT_KEY; this._limit = options.limit || DEFAULT_LIMIT; } /** * @inheritDoc */ public setupOnce(): void { addGlobalEventProcessor((event: Event, hint?: EventHint) => { const self = getCurrentHub().getIntegration(LinkedErrors); if (self) { const handler = self._handler && self._handler.bind(self); return typeof handler === 'function' ? handler(event, hint) : event; } return event; }); } /** * @inheritDoc */ private _handler(event: Event, hint?: EventHint): PromiseLike<Event> { if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) { return SyncPromise.resolve(event); } return new SyncPromise<Event>(resolve => { void 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); }); }); } /** * @inheritDoc */ private _walkErrorTree(error: ExtendedError, key: string, stack: Exception[] = []): PromiseLike<Exception[]> { if (!isInstanceOf(error[key], Error) || stack.length + 1 >= this._limit) { return SyncPromise.resolve(stack); } return new SyncPromise<Exception[]>((resolve, reject) => { void getExceptionFromError(error[key]) .then((exception: Exception) => { void this._walkErrorTree(error[key], key, [exception, ...stack]) .then(resolve) .then(null, () => { reject(); }); }) .then(null, () => { reject(); }); }); } }
Trovare la differenza