1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { truncateString } from "https://esm.town/v/patrickjm/truncateString?v=2";
import { runs as runs2 } from "https://esm.town/v/stevekrouse/runs";
export function runErrorEmail(data) {
type Then<T> = T extends Promise<infer U> ? U : never;
let runs = data.data as Then<
ReturnType<typeof runs2>
>["data"];
const lis = runs.map((run) => {
let name = `${run.val.username}.${run.val.name}`;
let valLink = `https://val.town/v/${name}`;
let errorLink = `${valLink}/evaluations/${run.id}`;
let time = run.runEndAt;
let errorMessage = typeof run.error === "string"
? run.error
: run.error.message;
return `<li>
<a href="${valLink}">${name}</a>
-
<a href="${errorLink}">${time}</a>
-
<pre>${truncateString(errorMessage, 200)}</pre>
</li>`;
}).join("\n");
let ul = "<ul>" + lis + "</ul>";
return ul;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023