How to use the @sentry/node.Severity.Warning function in @sentry/node

To help you get started, we’ve selected a few @sentry/node 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 shfshanyue / apollo-server-starter / lib / error.ts View on Github external
export function formatError (error: GraphQLError): GraphQLFormattedError {
  let code: string = _.get(error, 'extensions.code', 'Error')
  let info: any
  let level = Severity.Error

  const originalError: any = error.originalError
  if (isAxiosError(originalError)) {
    code = `Request${originalError.code}`
  } else if (isJoiValidationError(originalError)) {
    code = 'JoiValidationError'
    info = originalError.details
  } else if (isSequelizeError(originalError)) {
    code = originalError.name
    if (isUniqueConstraintError(originalError)) {
      info = originalError.fields
      level = Severity.Warning
    }
  } else if (isApolloError(originalError)){
    level = originalError.level || Severity.Warning
  } else if (isError(originalError)) {
    code = _.get(originalError, 'code', originalError.name)
    level = Severity.Fatal
  }

  const formatError = {
    ...error,
    extensions: {
      ..._.get(error, 'extensions', {}),
      code,
      info
    }
  }
github shfshanyue / apollo-server-starter / lib / error.ts View on Github external
constructor (message: string, code: keyof typeof APP_ERROR_CODE = 'BadRequest', properties: Record = {}) {
    super(message, `App${code}`, {
      level: Severity.Warning,
      ...properties
    })
  }
}
github shfshanyue / apollo-server-starter / lib / error.ts View on Github external
let level = Severity.Error

  const originalError: any = error.originalError
  if (isAxiosError(originalError)) {
    code = `Request${originalError.code}`
  } else if (isJoiValidationError(originalError)) {
    code = 'JoiValidationError'
    info = originalError.details
  } else if (isSequelizeError(originalError)) {
    code = originalError.name
    if (isUniqueConstraintError(originalError)) {
      info = originalError.fields
      level = Severity.Warning
    }
  } else if (isApolloError(originalError)){
    level = originalError.level || Severity.Warning
  } else if (isError(originalError)) {
    code = _.get(originalError, 'code', originalError.name)
    level = Severity.Fatal
  }

  const formatError = {
    ...error,
    extensions: {
      ..._.get(error, 'extensions', {}),
      code,
      info
    }
  }
  Sentry.withScope(scope => {
    scope.setTag('code', code)
    scope.setLevel(level)