MCPcopy
hub / github.com/vercel/chatbot / toResponse

Method toResponse

lib/errors.ts:53–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51 }
52
53 public toResponse() {
54 const code: ErrorCode = `${this.type}:${this.surface}`;
55 const visibility = visibilityBySurface[this.surface];
56
57 const { message, cause, statusCode } = this;
58
59 if (visibility === 'log') {
60 console.error({
61 code,
62 message,
63 cause,
64 });
65
66 return Response.json(
67 { code: '', message: 'Something went wrong. Please try again later.' },
68 { status: statusCode },
69 );
70 }
71
72 return Response.json({ code, message, cause }, { status: statusCode });
73 }
74}
75
76export function getMessageByErrorCode(errorCode: ErrorCode): string {

Callers 10

POSTFunction · 0.80
DELETEFunction · 0.80
GETFunction · 0.80
GETFunction · 0.80
POSTFunction · 0.80
DELETEFunction · 0.80
GETFunction · 0.80
PATCHFunction · 0.80
GETFunction · 0.80
GETFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected