From 521f2721d5ba389eb8eb40c700c0e656ea1dc174 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Mon, 28 May 2018 11:24:22 +0200 Subject: [PATCH 1/2] Doc about server exception option in ErrorPlugin --- plugins/error.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/error.rst b/plugins/error.rst index 00df237..d330a3e 100644 --- a/plugins/error.rst +++ b/plugins/error.rst @@ -36,3 +36,8 @@ writing a library around an API, the best practice is to have the client convert domain objects, and transform HTTP errors into meaningful domain exceptions. In that scenario, the ErrorPlugin is not needed. It is more efficient to check the HTTP status codes yourself than throwing and catching exceptions. + +If you need to handle 4XX responses, as having a 404 can have meaning in your http client, but sill want +exception for 5XX responses, you can set the ``only_server_exception`` option to ``true``:: + + $errorPlugin = new ErrorPlugin(['only_server_exception' => true]); From f6c7ed3ba0a9acc9342814d7e9e47e5eed4e9559 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Mon, 28 May 2018 16:07:13 +0200 Subject: [PATCH 2/2] Fix wording --- plugins/error.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/error.rst b/plugins/error.rst index d330a3e..943378a 100644 --- a/plugins/error.rst +++ b/plugins/error.rst @@ -37,7 +37,7 @@ domain objects, and transform HTTP errors into meaningful domain exceptions. In the ErrorPlugin is not needed. It is more efficient to check the HTTP status codes yourself than throwing and catching exceptions. -If you need to handle 4XX responses, as having a 404 can have meaning in your http client, but sill want -exception for 5XX responses, you can set the ``only_server_exception`` option to ``true``:: +If your application handles responses with 4xx status codes, but needs exceptions for 5xx status codes only, +you can set the option ``only_server_exception`` to ``true``:: $errorPlugin = new ErrorPlugin(['only_server_exception' => true]);