From f2b2b882a413288db7c6c4cf5ba2ce0a832959fc Mon Sep 17 00:00:00 2001 From: Martijn de Boer Date: Mon, 1 Jun 2020 13:28:16 +0200 Subject: [PATCH] Fix exception parameter, update README --- README.md | 4 +++- lib/Context.php | 2 -- lib/WAException.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 853c9c0..aa16cc9 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,9 @@ Objects like Post or Collection will update automagically after calling a save/g Authentication is done on the Context. If you want to authenticate multiple users for some reason, use multiple contexts. Upon logging in you should store the access token for future sessions. Logout when you need to, don't keep tokens layout around. -# Work in progress +All errors are transformed to WAException objects, which are catchable. + +# Supports the following api endpoints (near) completely - [x] Authentication - [x] Posts diff --git a/lib/Context.php b/lib/Context.php index e462ae9..ce86bec 100644 --- a/lib/Context.php +++ b/lib/Context.php @@ -69,8 +69,6 @@ public function request( string $url, ?string $postdata = null, ?string $customR if ( (int) $statusCode >= 400 ) { throw new WAException( null, $statusCode ); - - return null; } if ( $output !== false && !empty( $output ) ) { diff --git a/lib/WAException.php b/lib/WAException.php index 6b7499a..d62b1b7 100644 --- a/lib/WAException.php +++ b/lib/WAException.php @@ -18,7 +18,7 @@ class WAException extends \Exception 503 => "Server Error" ); - function __construct( $message = null, $code = 0, Exception $previous = null ) + function __construct( $message = null, $code = 0, \Exception $previous = null ) { if ( isset( $this->exceptions[ $code ] ) ) { $message = $this->exceptions[ $code ];