@snapshot-labs/snapshot-sentry
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -112,3 +112,4 @@ "use strict"; | ||
function normalizedCaptureContext(e, captureContext) { | ||
if (!captureContext && !isJsonRpcError(e)) { | ||
const jsonRpcError = extractJsonRpcError(e); | ||
if (!captureContext && !jsonRpcError) { | ||
return; | ||
@@ -127,4 +128,4 @@ } | ||
} | ||
if (isJsonRpcError(e)) { | ||
_captureContext.contexts.jsonRpcError = e; | ||
if (jsonRpcError) { | ||
_captureContext.contexts.jsonRpcError = jsonRpcError; | ||
} | ||
@@ -135,4 +136,5 @@ return _captureContext; | ||
function normalizedError(e) { | ||
if (isJsonRpcError(e)) { | ||
return new Error(e.message); | ||
const jsonRpcError = extractJsonRpcError(e); | ||
if (jsonRpcError) { | ||
return new Error(jsonRpcError.message); | ||
} | ||
@@ -145,4 +147,12 @@ else if (typeof e === 'string') { | ||
exports.normalizedError = normalizedError; | ||
function extractJsonRpcError(e) { | ||
if (isJsonRpcError(e.error)) { | ||
return e.error; | ||
} | ||
else if (isJsonRpcError(e)) { | ||
return e; | ||
} | ||
} | ||
function isJsonRpcError(e) { | ||
return e.hasOwnProperty('code') && e.hasOwnProperty('message') && e.hasOwnProperty('data'); | ||
return e?.hasOwnProperty('code') && e?.hasOwnProperty('message') && e?.hasOwnProperty('data'); | ||
} |
{ | ||
"name": "@snapshot-labs/snapshot-sentry", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -104,3 +104,5 @@ import * as Sentry from '@sentry/node'; | ||
export function normalizedCaptureContext(e: any, captureContext?: any) { | ||
if (!captureContext && !isJsonRpcError(e)) { | ||
const jsonRpcError = extractJsonRpcError(e); | ||
if (!captureContext && !jsonRpcError) { | ||
return; | ||
@@ -123,4 +125,4 @@ } | ||
if (isJsonRpcError(e)) { | ||
_captureContext.contexts.jsonRpcError = e; | ||
if (jsonRpcError) { | ||
_captureContext.contexts.jsonRpcError = jsonRpcError; | ||
} | ||
@@ -132,4 +134,6 @@ | ||
export function normalizedError(e: any) { | ||
if (isJsonRpcError(e)) { | ||
return new Error(e.message); | ||
const jsonRpcError = extractJsonRpcError(e); | ||
if (jsonRpcError) { | ||
return new Error(jsonRpcError.message); | ||
} else if (typeof e === 'string') { | ||
@@ -142,4 +146,12 @@ return new Error(e); | ||
function extractJsonRpcError(e: any) { | ||
if (isJsonRpcError(e.error)) { | ||
return e.error; | ||
} else if (isJsonRpcError(e)) { | ||
return e; | ||
} | ||
} | ||
function isJsonRpcError(e: any) { | ||
return e.hasOwnProperty('code') && e.hasOwnProperty('message') && e.hasOwnProperty('data'); | ||
return e?.hasOwnProperty('code') && e?.hasOwnProperty('message') && e?.hasOwnProperty('data'); | ||
} |
15267
287