interface Props {
  error: unknown
}

export function ErrorBox({ error }: Props) {
  let message: string
  if (error instanceof Error) {
    message = error.message
  } else if (typeof error === 'string') {
    message = error
  } else if (error && typeof error === 'object' && 'message' in error) {
    message = String((error as { message: unknown }).message)
  } else {
    message = 'Unknown error'
  }
  return (
    <div className="rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-800">
      <span className="font-semibold">Error:</span> {message}
    </div>
  )
}
