Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typo README.md / update NoGatewayAvailableException.php #349

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ $easySms->send($phone_number, [
'account' => '',
'password' => '',
'needstatus' => false,
'channel' => \Overtrue\EasySms\Gateways\ChuanglanV1Gateway::CHANNEL_NORMAL_CODE,
'channel' => \Overtrue\EasySms\Gateways\Chuanglanv1Gateway::CHANNEL_NORMAL_CODE,
],
```
发送示例:
Expand All @@ -549,7 +549,7 @@ $easySms->send(18888888888, [
'account' => '',
'password' => '',
'needstatus' => false,
'channel' => \Overtrue\EasySms\Gateways\ChuanglanV1Gateway::CHANNEL_VARIABLE_CODE,
'channel' => \Overtrue\EasySms\Gateways\Chuanglanv1Gateway::CHANNEL_VARIABLE_CODE,
],
```
发送示例:
Expand Down
12 changes: 12 additions & 0 deletions src/Exceptions/NoGatewayAvailableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ public function getResults()
return $this->results;
}

/**
* @return array
*/
public function getAllResults()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个方法的作用是啥?如果仅仅是列出每个网关的报错,那么只有 message 恐怕不太具有多大意义,我的建议是这块交由应用自身去处理,想要记日志也好,报错信息也好,由应用自身决定展示成什么样。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

作用是在当前配置的所有网关都失败的情况下,获取所有网关失败的原因。
getResults 方法也可以获取所有的网关错误,但是不同的网关错误信息字段名是不一致的,交由应用自身去处理的话逻辑重复太多了。

不过我觉的你说的也有道理...

{
$results = [];
foreach ($this->exceptions as $gateway => $exception) {
$results[$gateway] = $exception->getMessage();
}
return $results;
}

/**
* @param string $gateway
*
Expand Down