Эх сурвалжийг харах

修复日志记录问题和状态返回不正确问题

zhusiqing 4 жил өмнө
parent
commit
623e0c5e53

+ 2 - 1
src/middlewares/logs.ts

@@ -12,9 +12,10 @@ export = () => {
     };
     };
     return loggerMiddleware(ctx, next)
     return loggerMiddleware(ctx, next)
       .catch(error => {
       .catch(error => {
-        const { body, status, message } = error;
+        const { body, status = 500, message } = error;
         const errorText = `res: ${JSON.stringify({ status, message, body })}`;
         const errorText = `res: ${JSON.stringify({ status, message, body })}`;
         ctx.$log.error(errorText);
         ctx.$log.error(errorText);
+        ctx.status = status
       });
       });
   };
   };
 };
 };