import{runApiFunctionHandler as a}from"./api-functions-handler-runner.js";import{TimeoutExceededError as n}from"./errors.js";import o from"../../utils/reporter/logger.js";async function d(s,t,r,m){try{return await a(r,s,t)}catch(e){return o.error(`[${r.requestHandlerId}] ${e.stack}`),e.name==="RequestBodySizeLimitError"?s.json({message:e.message},{status:413}):e.name==="ResponseSizeLimitError"?s.json({message:e.message},{status:500}):e.name==="MemoryUsageLimitError"?s.json({message:e.message},{status:502}):e instanceof n?s.json({message:e.message},{status:504}):process.env.NODE_ENV==="development"?s.json({message:e.message},{status:500}):s.json({message:"Internal server error"},{status:500})}}export{d as default};
