From 4d3941ee2e37b5d217d1a376c171c71a0cbb4850 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 8 Jul 2022 19:43:43 +0800 Subject: [PATCH] refactor(connector): use raw error for config guard (#1484) --- packages/connector-alipay-native/src/index.ts | 2 +- packages/connector-alipay/src/index.ts | 2 +- packages/connector-aliyun-dm/src/index.ts | 2 +- packages/connector-aliyun-sms/src/index.ts | 2 +- packages/connector-facebook/src/index.ts | 2 +- packages/connector-github/src/index.ts | 2 +- packages/connector-google/src/index.ts | 2 +- packages/connector-sendgrid-mail/src/index.ts | 2 +- packages/connector-smtp/src/index.ts | 2 +- packages/connector-twilio-sms/src/index.ts | 2 +- packages/connector-wechat-native/src/index.ts | 2 +- packages/connector-wechat/src/index.ts | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/connector-alipay-native/src/index.ts b/packages/connector-alipay-native/src/index.ts index b27aab0ce..3603e4265 100644 --- a/packages/connector-alipay-native/src/index.ts +++ b/packages/connector-alipay-native/src/index.ts @@ -53,7 +53,7 @@ export default class AlipayNativeConnector implements SocialConnector { const result = alipayNativeConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-alipay/src/index.ts b/packages/connector-alipay/src/index.ts index cb3254854..e080664a1 100644 --- a/packages/connector-alipay/src/index.ts +++ b/packages/connector-alipay/src/index.ts @@ -53,7 +53,7 @@ export default class AlipayConnector implements SocialConnector { const result = alipayConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-aliyun-dm/src/index.ts b/packages/connector-aliyun-dm/src/index.ts index 62fc944b3..bc1a6dadc 100644 --- a/packages/connector-aliyun-dm/src/index.ts +++ b/packages/connector-aliyun-dm/src/index.ts @@ -28,7 +28,7 @@ export default class AliyunDmConnector implements EmailConnector { const result = aliyunDmConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-aliyun-sms/src/index.ts b/packages/connector-aliyun-sms/src/index.ts index f79222cfe..8647a236e 100644 --- a/packages/connector-aliyun-sms/src/index.ts +++ b/packages/connector-aliyun-sms/src/index.ts @@ -23,7 +23,7 @@ export default class AliyunSmsConnector implements SmsConnector { const result = aliyunSmsConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-facebook/src/index.ts b/packages/connector-facebook/src/index.ts index 93d413007..d40ee4d85 100644 --- a/packages/connector-facebook/src/index.ts +++ b/packages/connector-facebook/src/index.ts @@ -42,7 +42,7 @@ export default class FacebookConnector implements SocialConnector { const result = facebookConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-github/src/index.ts b/packages/connector-github/src/index.ts index 51931b0ec..f9104d56c 100644 --- a/packages/connector-github/src/index.ts +++ b/packages/connector-github/src/index.ts @@ -38,7 +38,7 @@ export default class GithubConnector implements SocialConnector { const result = githubConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-google/src/index.ts b/packages/connector-google/src/index.ts index 1b8fae10b..1aad78968 100644 --- a/packages/connector-google/src/index.ts +++ b/packages/connector-google/src/index.ts @@ -40,7 +40,7 @@ export default class GoogleConnector implements SocialConnector { const result = googleConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-sendgrid-mail/src/index.ts b/packages/connector-sendgrid-mail/src/index.ts index df4b81cbb..1dcc12f33 100644 --- a/packages/connector-sendgrid-mail/src/index.ts +++ b/packages/connector-sendgrid-mail/src/index.ts @@ -29,7 +29,7 @@ export default class SendGridMailConnector implements EmailConnector { const result = sendGridMailConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-smtp/src/index.ts b/packages/connector-smtp/src/index.ts index 3a4563539..c477275eb 100644 --- a/packages/connector-smtp/src/index.ts +++ b/packages/connector-smtp/src/index.ts @@ -23,7 +23,7 @@ export default class SmtpConnector implements EmailConnector { const result = smtpConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-twilio-sms/src/index.ts b/packages/connector-twilio-sms/src/index.ts index 8b033322a..42c831c70 100644 --- a/packages/connector-twilio-sms/src/index.ts +++ b/packages/connector-twilio-sms/src/index.ts @@ -22,7 +22,7 @@ export default class TwilioSmsConnector implements SmsConnector { const result = twilioSmsConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-wechat-native/src/index.ts b/packages/connector-wechat-native/src/index.ts index c4828c0cc..ef720b035 100644 --- a/packages/connector-wechat-native/src/index.ts +++ b/packages/connector-wechat-native/src/index.ts @@ -42,7 +42,7 @@ export default class WechatNativeConnector implements SocialConnector { const result = wechatNativeConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } }; diff --git a/packages/connector-wechat/src/index.ts b/packages/connector-wechat/src/index.ts index 3d1282546..cab6e545c 100644 --- a/packages/connector-wechat/src/index.ts +++ b/packages/connector-wechat/src/index.ts @@ -43,7 +43,7 @@ export default class WechatConnector implements SocialConnector { const result = wechatConfigGuard.safeParse(config); if (!result.success) { - throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error.message); + throw new ConnectorError(ConnectorErrorCodes.InvalidConfig, result.error); } };