CIA Compliance Manager — API Documentation - v1.1.50
    Preparing search index...

    Function formatErrorMessage

    • Format an error message from various error types

      Extracts error messages from various error formats including Error objects, objects with message properties, and primitives. Provides fallback message for null/undefined or unrecognized error formats.

      Parameters

      • error: unknown

        Error value of unknown type

      Returns string

      Formatted error message string

      // Error object
      formatErrorMessage(new Error('Failed')) // 'Failed'

      // Object with message
      formatErrorMessage({ message: 'Invalid' }) // 'Invalid'

      // String
      formatErrorMessage('Something wrong') // 'Something wrong'

      // Null/undefined
      formatErrorMessage(null) // 'An unknown error occurred'
      formatErrorMessage(undefined) // 'An unknown error occurred'

      // Object without message
      formatErrorMessage({ code: 500 }) // 'An unknown error occurred'

      // Usage in error display
      const handleError = (err: unknown) => {
      const message = formatErrorMessage(err);
      showNotification(message);
      };