# Function toErrorMessage

- toErrorMessage(error: unknown): string

  Extract a safe, human-readable error message from an unknown caught value. Returns `error.message` for Error instances; `'Unknown error'` otherwise. Avoids `String(error)` which can produce `"[object Object]"` for non-Error throws and may expose custom `toString()` output unexpectedly.

  #### Parameters

  - error: unknown

    Caught error value (unknown type from catch clause)

  #### Returns string

  Human-readable error message safe for audit logging

  - Defined in utils/auditLogger.ts:422