no message
This commit is contained in:
20
Question16-Exception/Ex05.php
Normal file
20
Question16-Exception/Ex05.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Ex05 上級 例外処理 - 実在するAPIへの呼び出し]
|
||||
*
|
||||
* 難易度:上級
|
||||
*
|
||||
* TODO:
|
||||
* 1. 関数 callAPI($url) を作成してください。
|
||||
* - $url が有効なURL形式でない場合は、InvalidArgumentException を投げる。
|
||||
* - $url を用いて、実在するAPI(例:"https://jsonplaceholder.typicode.com/todos/1")への GET リクエストを行う。
|
||||
* - API呼び出しに失敗した場合は、RuntimeException を投げる。
|
||||
* - 正常に呼び出せた場合は、APIからのレスポンス(文字列)を返す。
|
||||
*
|
||||
* 2. callAPI() を呼び出す際、try-catch-finally ブロックを使用してください。
|
||||
* - InvalidArgumentException と RuntimeException を個別にキャッチし、エラーメッセージを出力する。
|
||||
* - finally ブロックで「API call attempt finished.」というメッセージを必ず出力する。
|
||||
*
|
||||
*
|
||||
*/
|
||||
Reference in New Issue
Block a user