Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/client/test/error-sentence.test.ts?format=json
30 linespinch 100%Last change pinch in version 49, 1 version changed it
1// errorSentence: what an error answer says, from JSON or from the host's HTML error page.
2
3import assert from "node:assert/strict";
4import { test } from "node:test";
5import { errorSentence } from "../src/api-error.ts";
6
7test("a JSON answer gives its error, else its reason", () => {
8 assert.equal(errorSentence('{"error":"no such draft"}'), "no such draft");
9 assert.equal(errorSentence('{"reason":"paused"}'), "paused");
10 assert.equal(errorSentence("plain words"), "plain words");
11});
13test("an HTML error page is said by its title and Ray ID, not its first lines", () => {
14 const page = `<!DOCTYPE html>
15<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
16<head>
17<title>Worker threw exception | example.workers.dev | Cloudflare</title>
18</head>
19<body>${"<div></div>\n".repeat(50)}
20<span>Cloudflare Ray ID: <strong class="font-semibold">8c1f2e3d4a5b6c7d</strong></span>
21</body></html>`;
22 assert.equal(
23 errorSentence(page),
24 'an HTML error page titled "Worker threw exception | example.workers.dev | Cloudflare" (Ray ID 8c1f2e3d4a5b6c7d), not the server\'s own answer: the server failed before it could say why',
25 );
26 assert.equal(
27 errorSentence("<html><body>oops</body></html>"),
28 "an HTML error page, not the server's own answer: the server failed before it could say why",
29 );
30});