فهرست منبع

improve error handling

Yuki Takei 5 سال پیش
والد
کامیت
df8bdf80f4
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      packages/slackbot-proxy/src/middlewares/authorizer.ts

+ 6 - 4
packages/slackbot-proxy/src/middlewares/authorizer.ts

@@ -50,13 +50,14 @@ export class AuthorizeCommandMiddleware implements IMiddleware {
       result = await this.installerService.installer.authorize(query);
       result = await this.installerService.installer.authorize(query);
 
 
       if (result.botToken == null) {
       if (result.botToken == null) {
-        throw new Error(`The installation for the team(${teamId || enterpriseId}) has no botToken`);
+        res.writeHead(403, `The installation for the team(${teamId || enterpriseId}) has no botToken`);
+        return res.end();
       }
       }
     }
     }
     catch (e) {
     catch (e) {
       this.logger.error(e.message);
       this.logger.error(e.message);
 
 
-      res.writeHead(403, e.message);
+      res.writeHead(500, e.message);
       return res.end();
       return res.end();
     }
     }
 
 
@@ -109,13 +110,14 @@ export class AuthorizeInteractionMiddleware implements IMiddleware {
       result = await this.installerService.installer.authorize(query);
       result = await this.installerService.installer.authorize(query);
 
 
       if (result.botToken == null) {
       if (result.botToken == null) {
-        throw new Error(`The installation for the team(${teamId || enterpriseId}) has no botToken`);
+        res.writeHead(403, `The installation for the team(${teamId || enterpriseId}) has no botToken`);
+        return res.end();
       }
       }
     }
     }
     catch (e) {
     catch (e) {
       this.logger.error(e.message);
       this.logger.error(e.message);
 
 
-      res.writeHead(403, e.message);
+      res.writeHead(500, e.message);
       return res.end();
       return res.end();
     }
     }