Framework guides
Generic Node.js
npm install errorcoreInitialize Errorcore before creating servers, clients, queues, or workers.
import http from "node:http";
import { captureError, flush, init, wrapHandler } from "errorcore";
init({
service: process.env.ERRORCORE_SERVICE_NAME,
deploymentEnv: process.env.ERRORCORE_ENVIRONMENT,
transport: {
type: "http",
url: process.env.ERRORCORE_INGEST_URL ?? "https://api-production-7ecf.up.railway.app/v1/ingest",
apiKey: process.env.ERRORCORE_API_KEY,
},
encryptionKey: process.env.ERRORCORE_DEK,
});
async function handler(request, response) {
const path = new URL(request.url ?? "/", "http://application.local").pathname;
if (request.method === "GET" && path === "/errorcore-test") {
captureError(new Error("errorcore test error"));
await flush();
response.writeHead(202, { "content-type": "application/json" });
response.end(JSON.stringify({ sent: true }));
return;
}
// Handle the rest of your application routes here.
}
const server = http.createServer(wrapHandler(handler));wrapHandler() attaches request context to captures. Call captureError(error) wherever your service intentionally handles an error instead of letting it reach the SDK's process-level handlers.