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

Page クラスのショートコードの例外補足が適切でなさそう #166

Closed
ikaruga777 opened this issue Jul 20, 2023 · 0 comments · Fixed by #175
Closed

Page クラスのショートコードの例外補足が適切でなさそう #166

ikaruga777 opened this issue Jul 20, 2023 · 0 comments · Fixed by #175

Comments

@ikaruga777
Copy link
Contributor

Product_Api クラスの fetchColorMeShop\Swagger\ApiException を送出します。

/**
* 商品データの取得
*
* @param int $product_id 商品ID (required)
* @throws \ColorMeShop\Swagger\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \ColorMeShop\Swagger\Model\InlineResponse2007
*/
public function fetch( $product_id ) {

一方、この関数を呼び出す Page クラスのショートコードでは RuntimeException でキャッチしています。この例外は ColorMeShop\Swagger\ApiException を継承していないので、 ColorMeShop\Swagger\ApiException 例外時に突き抜けてしまうように見えます。

try {
$product = $container['api.product_api']->fetch( $filtered_atts['product_id'] )['product'];
} catch ( \RuntimeException $e ) {
if ( $container['WP_DEBUG_LOG'] ) {
error_log( $e );
}
return '';
}

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