mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-29 04:25:52 +01:00
test: retain routine route server error diagnostics
This commit is contained in:
1 parent
bba63f5120
commit
35bcf3f62e
1 file changed
+14
-1
@@ -1,4 +1,4 @@
|
||||
import express from "express";
|
||||
import express, { type ErrorRequestHandler } from "express";
|
||||
import request from "supertest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
@@ -177,6 +177,19 @@ async function createApp(actor: Record<string, unknown>) {
|
||||
next();
|
||||
});
|
||||
app.use("/api", routineRoutes({} as any));
|
||||
const reportServerError: ErrorRequestHandler = (err, req, res, next) => {
|
||||
res.once("finish", () => {
|
||||
if (res.statusCode >= 500) {
|
||||
console.error("Routine route fixture returned a server error", {
|
||||
method: req.method,
|
||||
path: req.originalUrl,
|
||||
error: err,
|
||||
});
|
||||
}
|
||||
});
|
||||
next(err);
|
||||
};
|
||||
app.use(reportServerError);
|
||||
app.use(errorHandler);
|
||||
return app;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user