MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / getSentryErrorTitle

Function getSentryErrorTitle

pkg/webui/lib/errors/utils.js:323–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321 * @returns {string} The Sentry error title.
322 */
323export const getSentryErrorTitle = error => {
324 if (typeof error === 'string') {
325 return `invalid string error: "${error}"`
326 }
327 if (typeof error !== 'object') {
328 return `invalid error type: ${error}`
329 }
330
331 if (isBackend(error)) {
332 const title = error.message || error.message_format
333 if (hasValidDetails(error) && hasCauses(getBackendErrorDetails(error))) {
334 const rootCause = getBackendErrorRootCause(getBackendErrorDetails(error))
335 if (isBackendErrorDetails(rootCause)) {
336 const message =
337 'attributes' in rootCause
338 ? interpolate(rootCause.message_format, rootCause.attributes)
339 : rootCause.message_format
340
341 return `${title}; error:${rootCause.namespace}:${rootCause.name} (${message})`
342 }
343 }
344 return title
345 } else if (isFrontend(error)) {
346 return error.errorTitle.defaultMessage
347 } else if ('message' in error) {
348 return error.message
349 } else if ('code' in error) {
350 return error.code
351 } else if ('statusCode' in error) {
352 return `status code: ${error.statusCode}`
353 } else if ('id' in error && 'defaultMessage' in error) {
354 return error.defaultMessage
355 }
356
357 return 'untitled or empty error'
358}
359
360/**
361 * Returns the id of the error, used as message id,

Callers 2

utils_test.jsFile · 0.90
ingestErrorFunction · 0.85

Calls 8

isBackendFunction · 0.85
hasValidDetailsFunction · 0.85
hasCausesFunction · 0.85
getBackendErrorDetailsFunction · 0.85
getBackendErrorRootCauseFunction · 0.85
isBackendErrorDetailsFunction · 0.85
interpolateFunction · 0.85
isFrontendFunction · 0.85

Tested by

no test coverage detected