Files
dify/cli/src/errors/envelope.ts
Yunlu Wen a728e0ac69 feat: adding dify cli (#36348)
Co-authored-by: GareArc <garethcxy@dify.ai>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: L1nSn0w <l1nsn0w@qq.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: gigglewang <gigglewang@dify.ai>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
2026-05-26 01:12:36 +00:00

33 lines
748 B
TypeScript

import type { BaseError } from './base.js'
export type ErrorEnvelope = {
error: {
code: string
message: string
hint?: string
http_status?: number
method?: string
url?: string
}
}
export function toEnvelope(err: BaseError): ErrorEnvelope {
const payload: ErrorEnvelope['error'] = {
code: err.code,
message: err.message,
}
if (err.hint !== undefined)
payload.hint = err.hint
if (err.httpStatus !== undefined)
payload.http_status = err.httpStatus
if (err.method !== undefined)
payload.method = err.method
if (err.url !== undefined)
payload.url = err.url
return { error: payload }
}
export function renderEnvelope(err: BaseError): string {
return JSON.stringify(toEnvelope(err))
}