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

返回值和可能抛的Exception应该有更清晰的注释说明 #19

Open
icedfish opened this issue May 28, 2015 · 1 comment
Open

Comments

@icedfish
Copy link

class Charge extends ApiResource
{
    /**
     * @param string $id The ID of the charge to retrieve.
     * @param array|string|null $options
     *
     * @return Charge
     */
    public static function retrieve($id, $options = null)
    {
        return self::_retrieve($id, $options);
    }

Charge类的多个方法实际上都是会抛Exception的,比如上述retrieve()方法在$id非法时就会抛InvalidRequestError。

希望官方在SDK各个常用方法上标准清楚可能返回的Exception类型,开发的时候IDE会对没有捕捉的Excetion进行提示,调用者能更清楚的知道如何应对返回。

     /** eg:
     * @throws InvalidRequestError if the error is caused by the user.
     * @throws AuthenticationError if the error is caused by a lack of
     *    permissions.
     * @throws ApiError otherwise.
     */

其实retrieve()何时会返回string或者null我到现在都没明白,所以校验返回的时候很痛苦,只检查是否抛Exception不知是否够用。 希望增加类似的说明。

@samurai00
Copy link
Contributor

@icedfish 我们的 Charge,Refund ... 这些类,理论上都有可能抛出我们定义的任何一种 Exception 的。
不过我们会改进说明的,谢谢你的建议。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants