const { ERROR_LOG_API_URL } = require("./env"); async function reportError({ partofservice, error }) { try { await fetch(ERROR_LOG_API_URL, { method: "POST", headers: { "Content-Type": "application/json", "x-internal-api-key": process.env.INTERNAL_API_KEY || "", }, body: JSON.stringify({ service: "transit_api", partofservice, error, }), }); } catch (_) {} } function reportUnhandled(context, err) { const message = err?.message || String(err); const stack = err?.stack || message; log("error", context, { error: message, stack }); void reportError({ partofservice: context, error: stack }); } module.exports = { reportError, reportUnhandled };