Spec Clarification: Client MUST throw *most specific* subclass of WebApplicationException
diff --git a/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_api.adoc b/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_api.adoc index c3333a3..b5d2cd4 100644 --- a/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_api.adoc +++ b/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_api.adoc
@@ -31,3 +31,5 @@ include::_reactive_clients.adoc[] include::_executor_services.adoc[] + +include::_client_exceptions.adoc[]
diff --git a/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_exceptions.adoc b/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_exceptions.adoc new file mode 100644 index 0000000..3a54764 --- /dev/null +++ b/jaxrs-spec/src/main/asciidoc/chapters/client_api/_client_exceptions.adoc
@@ -0,0 +1,31 @@ +//// +******************************************************************* +* Copyright (c) 2022 Eclipse Foundation +* +* This specification document is made available under the terms +* of the Eclipse Foundation Specification License v1.0, which is +* available at https://www.eclipse.org/legal/efsl.php. +******************************************************************* +//// + +[[client_exceptions]] +=== Client Exceptions + +A method of the JAX-RS Client API that _nominally_ throws `WebApplicationException` +MUST _actually_ throw the _most specific_ exception subclass for the current response status code, +unless no such subclass is defined by the JAX-RS API. + +Only in the latter case the method MAY throw the `WebApplicationException` +class directly. + +The method MAY throw a direct or indirect subclass of the mandatory exception. + +Example: If a response has the status 404, a compliant implementation MUST NOT +throw `WebApplicationException(404)`, but instead MUST throw `NotFoundException`, +or a subclass of `NotFoundException`, because the description of `NotFoundException` +_exactly_ matches the status code 404. + +Example: If a response has the status 567, a compliant implementation MUST NOT +throw `WebApplicationException(567)` but instead MUST throw `ServerErrorException`, +or a subclass of `ServerErrorException`, because the description of `ServerErrorException` +_indirectly_ matches the status code 567 by matching the whole 5XX family of codes.
diff --git a/jaxrs-spec/src/main/asciidoc/chapters/providers/_exceptions_providers.adoc b/jaxrs-spec/src/main/asciidoc/chapters/providers/_exceptions_providers.adoc index 7003855..b36df94 100644 --- a/jaxrs-spec/src/main/asciidoc/chapters/providers/_exceptions_providers.adoc +++ b/jaxrs-spec/src/main/asciidoc/chapters/providers/_exceptions_providers.adoc
@@ -46,3 +46,4 @@ Note that the client runtime will only throw an instance of `WebApplicationException` (or any of its subclasses) as a result of a response from the server with status codes 3xx, 4xx or 5xx. +See <<client_exceptions>> for more details on `WebApplicationException`.