Something went wrong. Try again.
Atproto AMA app
Something went wrong. Try again.
2.2 kB · 52 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253export type AnswerContentOriginErrorCode = | "malformed-input" | "unsupported-origin" | "unsupported-collection" | "fetch-failed" | "ownership-mismatch" | "not-found" | "permalink-unresolved" | "unverifiable-url" | "conflicting-backlink" | "no-usable-text" | "publication-not-supported" | "verification-pending" | "ssrf-blocked";
const USER_MESSAGES: Record<AnswerContentOriginErrorCode, string> = { "malformed-input": "Invalid link input — must be an at:// URI, bsky.app URL, askimut permalink, or Standard.site article URL", "unsupported-origin": "This link format is not supported — use an at:// URI, bsky.app post URL, askimut permalink, or Standard.site article URL", "unsupported-collection": "This AT record type is not supported as Answer Content", "fetch-failed": "Could not fetch external content", "ownership-mismatch": "Cannot answer with someone else's content", "not-found": "Could not find the linked content", "permalink-unresolved": "Could not resolve the linked question's answer", "unverifiable-url": "This page does not advertise a verifiable Standard.site document — only Standard.site article pages are supported", "conflicting-backlink": "This page advertises multiple Standard.site documents — the linked record must be unambiguous", "no-usable-text": "This Standard.site document has no plain text content to display as an answer", "publication-not-supported": "Standard.site publications are containers, not Answer Content — paste a document URL or document AT-URI", "verification-pending": "Standard.site verification is not complete yet — the article page may still be deploying its document link; try again shortly", "ssrf-blocked": "Could not verify this URL",};
export class AnswerContentOriginError extends Error { readonly code: AnswerContentOriginErrorCode;
constructor(code: AnswerContentOriginErrorCode, message?: string) { super(message ?? USER_MESSAGES[code]); this.name = "AnswerContentOriginError"; this.code = code; }}
export function userMessageForCode(code: AnswerContentOriginErrorCode): string { return USER_MESSAGES[code];}