Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

602 B
Raw Blame
import { ApiError } from '@/api/client'
import { TransportError } from '@/api/transport'

export function toError(value: unknown): Error {
    return value instanceof Error ? value : new Error(String(value))
}

/** One line for a failed action: the server's own words when it sent some. */
export function actionErrorMessage(error: unknown): string {
    if (error instanceof ApiError) {
        return error.detail ?? `PostHog couldn't do that (error ${error.status}). Try again.`
    }
    if (error instanceof TransportError) {
        return error.message
    }
    return toError(error).message
}