This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 07d5d83859 Utility class cleanup
07d5d83859 is described below
commit 07d5d83859fe0bdb7f10ca6d6de5a07c137af9cb
Author: James Bognar <[email protected]>
AuthorDate: Wed Oct 29 15:35:44 2025 -0400
Utility class cleanup
---
TODO-completed.md | 36 ++++++
TODO.md | 2 -
.../org/apache/juneau/bean/openapi3/Items.java | 5 +-
.../org/apache/juneau/bean/openapi3/OpenApi.java | 3 +-
.../org/apache/juneau/bean/openapi3/Parameter.java | 6 +-
.../juneau/bean/openapi3/SecuritySchemeInfo.java | 7 +-
.../org/apache/juneau/bean/swagger/HeaderInfo.java | 6 +-
.../java/org/apache/juneau/bean/swagger/Items.java | 6 +-
.../apache/juneau/bean/swagger/ParameterInfo.java | 8 +-
.../apache/juneau/bean/swagger/SecurityScheme.java | 4 +-
.../org/apache/juneau/bean/swagger/Swagger.java | 3 +-
.../org/apache/juneau/assertions/Assertion.java | 3 +-
.../apache/juneau/common/utils/ThrowableUtils.java | 70 +++++++++++
.../apache/juneau/jena/RdfSerializerSession.java | 3 +-
.../main/java/org/apache/juneau/BeanContext.java | 10 +-
.../java/org/apache/juneau/BeanPropertyMeta.java | 3 +-
.../src/main/java/org/apache/juneau/Context.java | 6 +-
.../java/org/apache/juneau/collections/Args.java | 3 +-
.../main/java/org/apache/juneau/cp/BeanStore.java | 4 +-
.../org/apache/juneau/httppart/HttpPartSchema.java | 2 +-
.../java/org/apache/juneau/parser/ParserSet.java | 7 +-
.../org/apache/juneau/reflect/ExecutableInfo.java | 6 +-
.../java/org/apache/juneau/reflect/FieldInfo.java | 7 +-
.../apache/juneau/serializer/SerializerSet.java | 7 +-
.../main/java/org/apache/juneau/uon/UonWriter.java | 4 +-
.../org/apache/juneau/utils/ReflectionMap.java | 6 +-
.../main/java/org/apache/juneau/xml/Namespace.java | 8 +-
.../org/apache/juneau/xml/XmlParserSession.java | 3 +-
.../juneau/examples/rest/ContentComboTestBase.java | 3 +-
.../apache/juneau/microservice/Microservice.java | 4 +-
.../microservice/jetty/JettyMicroservice.java | 9 +-
.../apache/juneau/rest/client/ResponseHeader.java | 4 +-
.../org/apache/juneau/rest/client/RestClient.java | 2 +-
.../org/apache/juneau/rest/client/RestRequest.java | 7 +-
.../juneau/rest/client/remote/RemoteMeta.java | 4 +-
.../java/org/apache/juneau/http/HttpHeaders.java | 3 +-
.../java/org/apache/juneau/http/HttpParts.java | 3 +-
.../juneau/http/entity/SerializedEntity.java | 3 +-
.../juneau/http/header/BasicIntegerHeader.java | 4 +-
.../apache/juneau/http/header/BasicLongHeader.java | 4 +-
.../org/apache/juneau/http/header/IfRange.java | 4 +-
.../org/apache/juneau/http/header/RetryAfter.java | 4 +-
.../juneau/http/header/SerializedHeader.java | 6 +-
.../org/apache/juneau/http/part/BasicPart.java | 4 +-
.../apache/juneau/http/part/SerializedPart.java | 6 +-
.../apache/juneau/rest/mock/MockPathResolver.java | 8 +-
.../apache/juneau/rest/beans/BeanDescription.java | 5 +-
.../juneau/rest/httppart/RequestHeaders.java | 3 +-
.../org/apache/juneau/rest/util/RestUtils.java | 9 +-
.../apache/juneau/assertions/Assertion_Test.java | 2 +-
.../apache/juneau/bean/openapi3/OpenApi_Test.java | 2 +-
.../juneau/bean/swagger/SwaggerBuilder_Test.java | 10 +-
.../apache/juneau/bean/swagger/Swagger_Test.java | 2 +-
.../juneau/common/utils/ThrowableUtils_Test.java | 140 +++++++++++++++++++++
.../org/apache/juneau/http/BasicPart_Test.java | 4 +-
.../org/apache/juneau/http/HttpHeaders_Test.java | 4 +-
.../apache/juneau/http/SerializedHeader_Test.java | 2 +-
.../apache/juneau/http/SerializedPart_Test.java | 2 +-
.../http/header/BasicIntegerHeader_Test.java | 2 +-
.../juneau/http/header/BasicLongHeader_Test.java | 2 +-
.../apache/juneau/reflect/ExecutableInfo_Test.java | 4 +-
.../org/apache/juneau/reflect/FieldInfo_Test.java | 4 +-
.../org/apache/juneau/utils/ReflectionMapTest.java | 6 +-
63 files changed, 393 insertions(+), 130 deletions(-)
diff --git a/TODO-completed.md b/TODO-completed.md
index 2c77af8f3e..8b1918925d 100644
--- a/TODO-completed.md
+++ b/TODO-completed.md
@@ -221,6 +221,42 @@ This file contains TODO items that have been completed and
moved from TODO.md.
- **Status**: COMPLETED
- **Details**: Refactored codebase to use static imports for BctUtils
methods.
+## Exception Creation Utilities
+
+- **TODO-67** ✅ Add to ThrowableUtils: unsupportedOp, ioException.
+ - **Status**: COMPLETED
+ - **Details**: Added exception creation methods to `ThrowableUtils`
following the same pattern as `runtimeException()` and `illegalArg()`:
+ - `unsupportedOp(String msg, Object...args)` - Creates
`UnsupportedOperationException` with formatted message
+ - `unsupportedOp(Throwable cause, String msg, Object...args)` - Creates
`UnsupportedOperationException` with cause and formatted message
+ - `ioException(String msg, Object...args)` - Creates `IOException` with
formatted message
+ - `ioException(Throwable cause, String msg, Object...args)` - Creates
`IOException` with cause and formatted message
+ - Also added overloads with cause parameter for existing methods:
+ - `illegalArg(Throwable cause, String msg, Object...args)`
+ - `runtimeException(Throwable cause, String msg, Object...args)`
+ - All methods support `MessageFormat` style formatting with varargs
+ - Comprehensive unit tests added covering all new methods and overloads
(19 total tests)
+ - Tests verify message formatting, cause chaining, exception types, and
exception throwing
+
+- **TODO-68** ✅ Replace BasicRuntimeException with
ThrowableUtils.runtimeException.
+ - **Status**: COMPLETED
+ - **Details**: Replaced all instances of `throw new
BasicRuntimeException(...)` with `throw runtimeException(...)` across the
entire codebase:
+ - **45 source files** updated (excluding javadocs and generated files)
+ - Added `import static org.apache.juneau.common.utils.ThrowableUtils.*;`
to all affected files
+ - **File breakdown:**
+ - juneau-core/juneau-marshall: 11 files (BeanPropertyMeta,
ExecutableInfo, FieldInfo, Context, HttpPartSchema, BeanContext, SerializerSet,
ParserSet, Args, XmlParserSession, Namespace)
+ - juneau-core/juneau-marshall-rdf: 1 file (RdfSerializerSession)
+ - juneau-core/juneau-assertions: 1 file (Assertion)
+ - juneau-bean/juneau-bean-swagger-v2: 5 files (Swagger, Items,
HeaderInfo, SecurityScheme, ParameterInfo)
+ - juneau-bean/juneau-bean-openapi-v3: 4 files (Items,
SecuritySchemeInfo, Parameter, OpenApi)
+ - juneau-rest: 17 files (MockPathResolver, SerializedEntity,
HttpHeaders, HttpParts, SerializedPart, BasicPart, BasicIntegerHeader, IfRange,
BasicLongHeader, RetryAfter, SerializedHeader, RestRequest, ResponseHeader,
RestClient, RemoteMeta, RestUtils, BeanDescription)
+ - juneau-microservice: 2 files (JettyMicroservice, Microservice)
+ - juneau-examples: 1 file (ContentComboTestBase - test file)
+ - Additional files: UonWriter, ReflectionMap, BeanStore
+ - **Total replacements:** All `throw new BasicRuntimeException(...)` calls
replaced with `throw runtimeException(...)`
+ - Fixed several files that had missing or duplicate static imports
+ - **Compilation verified:** Full clean compile successful (`mvn clean
compile -DskipTests`)
+ - This change provides consistency across the codebase and leverages the
new utility methods from TODO-67
+
## Notes
Items are marked as completed when:
diff --git a/TODO.md b/TODO.md
index 800420d51c..1c9a726659 100644
--- a/TODO.md
+++ b/TODO.md
@@ -19,8 +19,6 @@ This file tracks pending tasks for the Apache Juneau project.
For completed item
- [ ] TODO-52 Use static imports for all method calls to Utils.
- [ ] TODO-54 Search for places in code where Calendar should be replaced with
ZonedDateTime.
- [ ] TODO-66 There are two ArrayUtilsTest classes whose tests should be
merged into CollectionUtils_Test.
-- [ ] TODO-67 Add to ThrowableUtils: unsupportedOp, ioException.
-- [ ] TODO-68 Replace BasicRuntimeException with
ThrowableUtils.runtimeException.
- [ ] TODO-69 Look for places in code where a(...) can be used.
- [ ] TODO-70 Look for instances of Arrays.asList that can be converted to
alist.
diff --git
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Items.java
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Items.java
index adf6b7fae9..3fc27e4936 100644
---
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Items.java
+++
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Items.java
@@ -17,16 +17,17 @@
package org.apache.juneau.bean.openapi3;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.collections.*;
+import org.apache.juneau.common.utils.*;
import org.apache.juneau.json.*;
/**
@@ -431,7 +432,7 @@ public class Items extends OpenApiElement {
*/
public Items setCollectionFormat(String value) {
if (isStrict() && ! contains(value, VALID_COLLECTION_FORMATS))
- throw new BasicRuntimeException("Invalid value passed
in to setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
VALID_COLLECTION_FORMATS);
+ throw runtimeException("Invalid value passed in to
setCollectionFormat(String). Value=''{0}'', valid values=[{1}]", value,
StringUtils.toCdl(VALID_COLLECTION_FORMATS));
collectionFormat = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/OpenApi.java
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/OpenApi.java
index 8321ebac42..2072b4927a 100644
---
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/OpenApi.java
+++
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/OpenApi.java
@@ -17,6 +17,7 @@
package org.apache.juneau.bean.openapi3;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
@@ -245,7 +246,7 @@ public class OpenApi extends OpenApiElement {
assertArgNotNullOrBlank("ref", ref);
assertArgNotNull("c", c);
if (! ref.startsWith("#/"))
- throw new BasicRuntimeException("Unsupported reference:
''{0}''", ref);
+ throw runtimeException("Unsupported reference:
''{0}''", ref);
try {
return new ObjectRest(this).get(ref.substring(1), c);
} catch (Exception e) {
diff --git
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Parameter.java
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Parameter.java
index 736caaa5a8..d388daa531 100644
---
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Parameter.java
+++
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/Parameter.java
@@ -17,13 +17,13 @@
package org.apache.juneau.bean.openapi3;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.collections.*;
import org.apache.juneau.common.utils.*;
import org.apache.juneau.marshaller.*;
@@ -356,7 +356,7 @@ public class Parameter extends OpenApiElement {
*/
public Parameter setIn(String value) {
if (isStrict() && ! StringUtils.contains(value, VALID_IN))
- throw new BasicRuntimeException("Invalid value passed
in to setIn(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_IN));
+ throw runtimeException("Invalid value passed in to
setIn(String). Value=''{0}'', valid values={1}", value, Json5.of(VALID_IN));
this.in = value;
return this;
}
@@ -402,7 +402,7 @@ public class Parameter extends OpenApiElement {
*/
public Parameter setStyle(String value) {
if (isStrict() && ! StringUtils.contains(value, VALID_STYLES))
- throw new BasicRuntimeException("Invalid value passed
in to setStyle(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_STYLES));
+ throw runtimeException("Invalid value passed in to
setStyle(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_STYLES));
this.style = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/SecuritySchemeInfo.java
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/SecuritySchemeInfo.java
index 608e795133..a24fe4bfc8 100644
---
a/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/SecuritySchemeInfo.java
+++
b/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/SecuritySchemeInfo.java
@@ -17,14 +17,15 @@
package org.apache.juneau.bean.openapi3;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.collections.*;
+import org.apache.juneau.common.utils.*;
/**
* Defines a security scheme that can be used by the operations.
@@ -340,7 +341,7 @@ public class SecuritySchemeInfo extends OpenApiElement {
*/
public SecuritySchemeInfo setIn(String value) {
if (isStrict() && ! contains(value, VALID_IN))
- throw new BasicRuntimeException("Invalid value passed
in to setIn(String). Value=''{0}'', valid values={1}", value, VALID_IN);
+ throw runtimeException("Invalid value passed in to
setIn(String). Value=''{0}'', valid values=[{1}]", value,
StringUtils.toCdl(VALID_IN));
in = value;
return this;
}
@@ -430,7 +431,7 @@ public class SecuritySchemeInfo extends OpenApiElement {
*/
public SecuritySchemeInfo setType(String value) {
if (isStrict() && ! contains(value, VALID_TYPES))
- throw new BasicRuntimeException("Invalid value passed
in to setType(String). Value=''{0}'', valid values={1}", value, VALID_TYPES);
+ throw runtimeException("Invalid value passed in to
setType(String). Value=''{0}'', valid values=[{1}]", value,
StringUtils.toCdl(VALID_TYPES));
type = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/HeaderInfo.java
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/HeaderInfo.java
index d1970141e2..e3ee3a779d 100644
---
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/HeaderInfo.java
+++
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/HeaderInfo.java
@@ -17,13 +17,13 @@
package org.apache.juneau.bean.swagger;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.common.collections.*;
import org.apache.juneau.marshaller.*;
@@ -453,7 +453,7 @@ public class HeaderInfo extends SwaggerElement {
*/
public HeaderInfo setCollectionFormat(String value) {
if (isStrict() && ! contains(value, VALID_COLLECTION_FORMATS))
- throw new BasicRuntimeException("Invalid value passed
in to setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_COLLECTION_FORMATS));
+ throw runtimeException("Invalid value passed in to
setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_COLLECTION_FORMATS));
collectionFormat = value;
return this;
}
@@ -735,7 +735,7 @@ public class HeaderInfo extends SwaggerElement {
*/
public HeaderInfo setType(String value) {
if (isStrict() && ! contains(value, VALID_TYPES))
- throw new BasicRuntimeException("Invalid value passed
in to setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
+ throw runtimeException("Invalid value passed in to
setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
type = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Items.java
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Items.java
index e430f0efcc..a58e980691 100644
---
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Items.java
+++
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Items.java
@@ -17,13 +17,13 @@
package org.apache.juneau.bean.swagger;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.common.collections.*;
import org.apache.juneau.marshaller.*;
@@ -426,7 +426,7 @@ public class Items extends SwaggerElement {
*/
public Items setCollectionFormat(String value) {
if (isStrict() && ! contains(value, VALID_COLLECTION_FORMATS))
- throw new BasicRuntimeException("Invalid value passed
in to setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_COLLECTION_FORMATS));
+ throw runtimeException("Invalid value passed in to
setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_COLLECTION_FORMATS));
collectionFormat = value;
return this;
}
@@ -679,7 +679,7 @@ public class Items extends SwaggerElement {
*/
public Items setType(String value) {
if (isStrict() && ! contains(value, VALID_TYPES))
- throw new BasicRuntimeException("Invalid value passed
in to setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
+ throw runtimeException("Invalid value passed in to
setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
type = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/ParameterInfo.java
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/ParameterInfo.java
index 12e48cc463..40e3c69899 100644
---
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/ParameterInfo.java
+++
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/ParameterInfo.java
@@ -17,13 +17,13 @@
package org.apache.juneau.bean.swagger;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.collections.*;
import org.apache.juneau.marshaller.*;
@@ -665,7 +665,7 @@ public class ParameterInfo extends SwaggerElement {
*/
public ParameterInfo setCollectionFormat(String value) {
if (isStrict() && ! contains(value, VALID_COLLECTION_FORMATS))
- throw new BasicRuntimeException("Invalid value passed
in to setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_COLLECTION_FORMATS));
+ throw runtimeException("Invalid value passed in to
setCollectionFormat(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_COLLECTION_FORMATS));
collectionFormat = value;
return this;
}
@@ -824,7 +824,7 @@ public class ParameterInfo extends SwaggerElement {
*/
public ParameterInfo setIn(String value) {
if (isStrict() && ! contains(value, VALID_IN))
- throw new BasicRuntimeException("Invalid value passed
in to setIn(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_IN));
+ throw runtimeException("Invalid value passed in to
setIn(String). Value=''{0}'', valid values={1}", value, Json5.of(VALID_IN));
in = value;
if ("path".equals(value))
required = true;
@@ -1025,7 +1025,7 @@ public class ParameterInfo extends SwaggerElement {
*/
public ParameterInfo setType(String value) {
if (isStrict() && ! contains(value, VALID_TYPES))
- throw new BasicRuntimeException("Invalid value passed
in to setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
+ throw runtimeException("Invalid value passed in to
setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
type = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/SecurityScheme.java
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/SecurityScheme.java
index c9aa771f54..71d171755d 100644
---
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/SecurityScheme.java
+++
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/SecurityScheme.java
@@ -17,13 +17,13 @@
package org.apache.juneau.bean.swagger;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.collections.*;
import org.apache.juneau.marshaller.*;
@@ -415,7 +415,7 @@ public class SecurityScheme extends SwaggerElement {
*/
public SecurityScheme setType(String value) {
if (isStrict() && ! contains(value, VALID_TYPES))
- throw new BasicRuntimeException("Invalid value passed
in to setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
+ throw runtimeException("Invalid value passed in to
setType(String). Value=''{0}'', valid values={1}", value,
Json5.of(VALID_TYPES));
type = value;
return this;
}
diff --git
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Swagger.java
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Swagger.java
index bd006d9954..43d3e6941b 100644
---
a/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Swagger.java
+++
b/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/Swagger.java
@@ -17,6 +17,7 @@
package org.apache.juneau.bean.swagger;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.internal.ConverterUtils.*;
@@ -457,7 +458,7 @@ public class Swagger extends SwaggerElement {
assertArgNotNullOrBlank("ref", ref);
assertArgNotNull("c", c);
if (! ref.startsWith("#/"))
- throw new BasicRuntimeException("Unsupported reference:
''{0}''", ref);
+ throw runtimeException("Unsupported reference:
''{0}''", ref);
try {
return new ObjectRest(this).get(ref.substring(1), c);
} catch (Exception e) {
diff --git
a/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/Assertion.java
b/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/Assertion.java
index a88d089acb..e7e880fb69 100644
---
a/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/Assertion.java
+++
b/juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/Assertion.java
@@ -17,6 +17,7 @@
package org.apache.juneau.assertions;
import static org.apache.juneau.common.utils.StringUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.io.*;
@@ -229,7 +230,7 @@ public class Assertion {
.run();
} catch (@SuppressWarnings("unused")
ExecutableException e) {
// If we couldn't create requested exception,
just throw a RuntimeException.
- throw new BasicRuntimeException(cause, msg);
+ throw runtimeException(cause, msg);
}
}
return new BasicAssertionError(cause, msg);
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/ThrowableUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/ThrowableUtils.java
index d1ddcceb0c..477a602bc9 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/ThrowableUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/ThrowableUtils.java
@@ -132,6 +132,18 @@ public class ThrowableUtils {
return new IllegalArgumentException(args.length == 0 ? msg :
f(msg, args));
}
+ /**
+ * Creates an {@link IllegalArgumentException} with a cause.
+ *
+ * @param cause The cause of the exception.
+ * @param msg The exception message.
+ * @param args The arguments to substitute into the message.
+ * @return A new IllegalArgumentException with the formatted message
and cause.
+ */
+ public static IllegalArgumentException illegalArg(Throwable cause,
String msg, Object...args) {
+ return new IllegalArgumentException(args.length == 0 ? msg :
f(msg, args), cause);
+ }
+
/**
* Creates a {@link RuntimeException}.
*
@@ -143,6 +155,64 @@ public class ThrowableUtils {
return new RuntimeException(args.length == 0 ? msg : f(msg,
args));
}
+ /**
+ * Creates a {@link RuntimeException} with a cause.
+ *
+ * @param cause The cause of the exception.
+ * @param msg The exception message.
+ * @param args The arguments to substitute into the message.
+ * @return A new RuntimeException with the formatted message and cause.
+ */
+ public static RuntimeException runtimeException(Throwable cause, String
msg, Object...args) {
+ return new RuntimeException(args.length == 0 ? msg : f(msg,
args), cause);
+ }
+
+ /**
+ * Creates an {@link UnsupportedOperationException}.
+ *
+ * @param msg The exception message.
+ * @param args The arguments to substitute into the message.
+ * @return A new UnsupportedOperationException with the formatted
message.
+ */
+ public static UnsupportedOperationException unsupportedOp(String msg,
Object...args) {
+ return new UnsupportedOperationException(args.length == 0 ? msg
: f(msg, args));
+ }
+
+ /**
+ * Creates an {@link UnsupportedOperationException} with a cause.
+ *
+ * @param cause The cause of the exception.
+ * @param msg The exception message.
+ * @param args The arguments to substitute into the message.
+ * @return A new UnsupportedOperationException with the formatted
message and cause.
+ */
+ public static UnsupportedOperationException unsupportedOp(Throwable
cause, String msg, Object...args) {
+ return new UnsupportedOperationException(args.length == 0 ? msg
: f(msg, args), cause);
+ }
+
+ /**
+ * Creates an {@link java.io.IOException}.
+ *
+ * @param msg The exception message.
+ * @param args The arguments to substitute into the message.
+ * @return A new IOException with the formatted message.
+ */
+ public static java.io.IOException ioException(String msg,
Object...args) {
+ return new java.io.IOException(args.length == 0 ? msg : f(msg,
args));
+ }
+
+ /**
+ * Creates an {@link java.io.IOException} with a cause.
+ *
+ * @param cause The cause of the exception.
+ * @param msg The exception message.
+ * @param args The arguments to substitute into the message.
+ * @return A new IOException with the formatted message and cause.
+ */
+ public static java.io.IOException ioException(Throwable cause, String
msg, Object...args) {
+ return new java.io.IOException(args.length == 0 ? msg : f(msg,
args), cause);
+ }
+
/**
* Searches through the cause chain of an exception to find an
exception of the specified type.
*
diff --git
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
index 0544dc8139..c9cb330762 100644
---
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
+++
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
@@ -18,6 +18,7 @@ package org.apache.juneau.jena;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.IOUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.jena.Constants.*;
@@ -246,7 +247,7 @@ public class RdfSerializerSession extends
WriterSerializerSession {
// Only apply properties with this prefix!
String propPrefix = LANG_PROP_MAP.get(ctx.getLanguage());
if (propPrefix == null)
- throw new BasicRuntimeException("Unknown RDF language
encountered: ''{0}''", ctx.getLanguage());
+ throw runtimeException("Unknown RDF language
encountered: ''{0}''", ctx.getLanguage());
// RDF/XML specific properties.
if (propPrefix.equals("rdfXml.")) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index 4151dd10e8..788a30a597 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -3527,7 +3527,7 @@ public class BeanContext extends Context {
else if (ci.isChildOf(Surrogate.class))
_swaps.addAll(SurrogateSwap.findObjectSwaps(ci.inner(), this));
else
- throw new
BasicRuntimeException("Invalid class {0} specified in BeanContext.swaps
property. Must be a subclass of ObjectSwap or Surrogate.", ci.inner());
+ throw runtimeException("Invalid class
{0} specified in BeanContext.swaps property. Must be a subclass of ObjectSwap
or Surrogate.", cn(ci.inner()));
}
});
swapArray = _swaps.toArray(new ObjectSwap[_swaps.size()]);
@@ -4267,7 +4267,7 @@ public class BeanContext extends Context {
if (cm2.isMap()) {
Class<?>[] pParams = (p.params().length == 0 ?
a(Object.class, Object.class) : p.params());
if (pParams.length != 2)
- throw new
BasicRuntimeException("Invalid number of parameters specified for Map (must be
2): {0}", pParams.length);
+ throw runtimeException("Invalid number
of parameters specified for Map (must be 2): {0}", pParams.length);
ClassMeta<?> keyType = resolveType(pParams[0],
cm2.getKeyType(), cm.getKeyType());
ClassMeta<?> valueType =
resolveType(pParams[1], cm2.getValueType(), cm.getValueType());
if (keyType.isObject() && valueType.isObject())
@@ -4277,9 +4277,9 @@ public class BeanContext extends Context {
if (cm2.isCollection() || cm2.isOptional()) {
Class<?>[] pParams = (p.params().length == 0 ?
a(Object.class) : p.params());
- if (pParams.length != 1)
- throw new
BasicRuntimeException("Invalid number of parameters specified for {1} (must be
1): {0}", pParams.length,
- (cm2.isCollection() ?
"Collection" : cm2.isOptional() ? "Optional" : "Array"));
+ if (pParams.length != 1)
+ throw runtimeException("Invalid number of
parameters specified for {1} (must be 1): {0}", pParams.length,
+ (cm2.isCollection() ? "Collection" :
cm2.isOptional() ? "Optional" : "Array"));
ClassMeta<?> elementType =
resolveType(pParams[0], cm2.getElementType(), cm.getElementType());
if (elementType.isObject())
return cm2;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index b83c900972..15e16287fb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -18,6 +18,7 @@ package org.apache.juneau;
import static org.apache.juneau.common.utils.ClassUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.lang.annotation.*;
@@ -155,7 +156,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
}
if (ci.isChildOf(Surrogate.class))
throw new UnsupportedOperationException("TODO -
Surrogate swaps not yet supported on bean properties.");
- throw new BasicRuntimeException("Invalid class used in
@Swap annotation. Must be a subclass of ObjectSwap or Surrogate. {0}", c);
+ throw runtimeException("Invalid class used in @Swap
annotation. Must be a subclass of ObjectSwap or Surrogate. {0}", cn(c));
}
Builder canRead() {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
index 159b31787b..b8bf855dce 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
@@ -656,7 +656,7 @@ public abstract class Context implements AnnotationProvider
{
);
// @formatter:on
if (cci == null)
- throw new BasicRuntimeException("Public
constructor not found: {0}({1})", cn(type), cn(this));
+ throw runtimeException("Public
constructor not found: {0}({1})", cn(type), cn(this));
CONTEXT_CONSTRUCTORS.put(type, cci);
}
return cci;
@@ -664,7 +664,7 @@ public abstract class Context implements AnnotationProvider
{
private Context innerBuild() {
if (type == null)
- throw new BasicRuntimeException("Type not
specified for context builder {0}", getClass().getName());
+ throw runtimeException("Type not specified for
context builder {0}", cn(getClass()));
if (nn(impl) && type.isInstance(impl))
return type.cast(impl);
if (nn(cache))
@@ -745,7 +745,7 @@ public abstract class Context implements AnnotationProvider
{
}
}
if (mi == null)
- throw new BasicRuntimeException("Could
not find builder create method on class {0}", type);
+ throw runtimeException("Could not find
builder create method on class {0}", cn(type));
BUILDER_CREATE_METHODS.put(type, mi);
}
Builder b = (Builder)mi.invoke(null);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/Args.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/Args.java
index 763265ef4a..0438bdcc24 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/Args.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/Args.java
@@ -18,6 +18,7 @@ package org.apache.juneau.collections;
import static java.util.stream.Collectors.*;
import static org.apache.juneau.common.utils.StringUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.util.*;
@@ -157,7 +158,7 @@ public class Args extends JsonMap {
if (startsWith(s, '-')) {
key = s.substring(1);
if (key.matches("\\d*"))
- throw new
BasicRuntimeException("Invalid optional key name ''{0}''", key);
+ throw runtimeException("Invalid
optional key name ''{0}''", key);
if (! containsKey(key))
put(key, new JsonList());
} else {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
index 350b05f726..2a61ea3aae 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
@@ -21,6 +21,7 @@ import static java.util.stream.Collectors.toList;
import static org.apache.juneau.collections.JsonMap.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.StringUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.common.utils.Utils.isEmpty;
@@ -30,7 +31,6 @@ import java.util.concurrent.*;
import java.util.function.*;
import java.util.stream.*;
-import org.apache.juneau.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.utils.*;
import org.apache.juneau.internal.*;
@@ -135,7 +135,7 @@ public class BeanStore {
if (nn(ci))
return ci.accessible().invoke(this);
- throw new BasicRuntimeException("Could not find a way
to instantiate class {0}", type);
+ throw runtimeException("Could not find a way to
instantiate class {0}", cn(type));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index 1448db4d0c..afe5e36921 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -383,7 +383,7 @@ public class HttpPartSchema {
else if
(a.annotationType().getName().startsWith("jakarta.validation.constraints."))
applyJakartaValidation(a);
else
- throw new
BasicRuntimeException("Builder.apply(@{0}) not defined", cn(a));
+ throw runtimeException("Builder.apply(@{0}) not
defined", cn(a));
return this;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSet.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSet.java
index 1fa3c6c0cd..b9e3f461a0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSet.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSet.java
@@ -18,6 +18,7 @@ package org.apache.juneau.parser;
import static java.util.stream.Collectors.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.util.*;
@@ -161,7 +162,7 @@ public class ParserSet {
if (Parser.class.isAssignableFrom(v)) {
l.add(createBuilder(v));
} else if (!
v.getSimpleName().equals("NoInherit")) {
- throw new
BasicRuntimeException("Invalid type passed to ParserSet.Builder.add(): {0}",
v.getName());
+ throw runtimeException("Invalid type
passed to ParserSet.Builder.add(): {0}", cn(v));
}
}
entries.addAll(0, l);
@@ -348,7 +349,7 @@ public class ParserSet {
} else if (Parser.class.isAssignableFrom(v)) {
l.add(createBuilder(v));
} else {
- throw new
BasicRuntimeException("Invalid type passed to ParserGrouup.Builder.set(): {0}",
v.getName());
+ throw runtimeException("Invalid type
passed to ParserGrouup.Builder.set(): {0}", cn(v));
}
}
entries = l;
@@ -375,7 +376,7 @@ public class ParserSet {
Parser.Builder x = (Parser.Builder)o;
Parser.Builder x2 = x.copy();
if (ne(x.getClass(), x2.getClass()))
- throw new BasicRuntimeException("Copy
method not implemented on class {0}", x.getClass().getName());
+ throw runtimeException("Copy method not
implemented on class {0}", cn(x));
x = x2;
if (nn(bcBuilder))
x.beanContext(bcBuilder);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
index eb6c9a08c4..d0220ed3b5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
@@ -19,6 +19,7 @@ package org.apache.juneau.reflect;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.PredicateUtils.*;
import static org.apache.juneau.common.utils.StringUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.lang.annotation.*;
@@ -26,7 +27,6 @@ import java.lang.reflect.*;
import java.util.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.reflect.*;
/**
@@ -613,7 +613,7 @@ public abstract class ExecutableInfo {
return false;
break;
default:
- throw new
BasicRuntimeException("Invalid flag for executable: {0}", f);
+ throw runtimeException("Invalid flag
for executable: {0}", f);
}
}
return true;
@@ -677,7 +677,7 @@ public abstract class ExecutableInfo {
return true;
break;
default:
- throw new
BasicRuntimeException("Invalid flag for executable: {0}", f);
+ throw runtimeException("Invalid flag
for executable: {0}", f);
}
}
return false;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
index f294b242a3..9311ab2caa 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
@@ -16,8 +16,9 @@
*/
package org.apache.juneau.reflect;
-import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.common.utils.PredicateUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
+import static org.apache.juneau.common.utils.Utils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -324,7 +325,7 @@ public class FieldInfo implements Comparable<FieldInfo> {
return false;
break;
default:
- throw new
BasicRuntimeException("Invalid flag for field: {0}", f);
+ throw runtimeException("Invalid flag
for field: {0}", f);
}
}
return true;
@@ -372,7 +373,7 @@ public class FieldInfo implements Comparable<FieldInfo> {
return true;
break;
default:
- throw new
BasicRuntimeException("Invalid flag for field: {0}", f);
+ throw runtimeException("Invalid flag
for field: {0}", f);
}
}
return false;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSet.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSet.java
index ea9bf5340c..7d78080ef1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSet.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSet.java
@@ -18,6 +18,7 @@ package org.apache.juneau.serializer;
import static java.util.stream.Collectors.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.util.*;
@@ -157,7 +158,7 @@ public class SerializerSet {
if (Serializer.class.isAssignableFrom(e)) {
l.add(createBuilder(e));
} else {
- throw new
BasicRuntimeException("Invalid type passed to SerializeGroup.Builder.add():
{0}", e.getName());
+ throw runtimeException("Invalid type
passed to SerializeGroup.Builder.add(): {0}", cn(e));
}
}
entries.addAll(0, l);
@@ -344,7 +345,7 @@ public class SerializerSet {
} else if
(Serializer.class.isAssignableFrom(e)) {
l.add(createBuilder(e));
} else {
- throw new
BasicRuntimeException("Invalid type passed to SerializeGroup.Builder.set():
{0}", e.getName());
+ throw runtimeException("Invalid type
passed to SerializeGroup.Builder.set(): {0}", cn(e));
}
}
entries = l;
@@ -371,7 +372,7 @@ public class SerializerSet {
Serializer.Builder x = (Serializer.Builder)o;
Serializer.Builder x2 = x.copy();
if (ne(x.getClass(), x2.getClass()))
- throw new BasicRuntimeException("Copy
method not implemented on class {0}", x.getClass().getName());
+ throw runtimeException("Copy method not
implemented on class {0}", cn(x));
x = x2;
if (nn(bcBuilder))
x.beanContext(bcBuilder);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonWriter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonWriter.java
index 2573a0f8e1..4e951013a0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonWriter.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonWriter.java
@@ -16,6 +16,8 @@
*/
package org.apache.juneau.uon;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
+
import java.io.*;
import org.apache.juneau.*;
@@ -281,7 +283,7 @@ public class UonWriter extends SerializerWriter {
*/
private UonWriter appendHex(int b) {
if (b > 255)
- throw new BasicRuntimeException("Invalid value passed
to appendHex. Must be in the range 0-255. Value={0}", b);
+ throw runtimeException("Invalid value passed to
appendHex. Must be in the range 0-255. Value={0}", b);
w('%').w(hexArray[b >>> 4]).w(hexArray[b & 0x0F]);
return this;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
index 5832371f25..dad8590dbc 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
@@ -19,13 +19,13 @@ package org.apache.juneau.utils;
import static java.lang.Character.*;
import static org.apache.juneau.collections.JsonMap.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.utils.*;
/**
@@ -182,7 +182,7 @@ public class ReflectionMap<V> {
*/
public Builder<V> append(String key, V value) {
if (isEmpty(key))
- throw new BasicRuntimeException("Invalid
reflection signature: [{0}]", key);
+ throw runtimeException("Invalid reflection
signature: [{0}]", key);
try {
splitNames(key, k -> {
if (k.endsWith(")")) {
@@ -206,7 +206,7 @@ public class ReflectionMap<V> {
}
});
} catch (@SuppressWarnings("unused")
IndexOutOfBoundsException e) {
- throw new BasicRuntimeException("Invalid
reflection signature: [{0}]", key);
+ throw runtimeException("Invalid reflection
signature: [{0}]", key);
}
return this;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
index 4db20580f9..44f1ff3fa5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/Namespace.java
@@ -16,12 +16,12 @@
*/
package org.apache.juneau.xml;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.util.*;
import java.util.concurrent.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.common.utils.*;
@@ -61,7 +61,7 @@ public class Namespace {
return (Namespace)o;
if (o instanceof CharSequence)
return of(o.toString());
- throw new BasicRuntimeException("Invalid object type passed to
Namespace.create(Object): ''{0}''", cn(o));
+ throw runtimeException("Invalid object type passed to
Namespace.create(Object): ''{0}''", cn(o));
}
/**
@@ -110,12 +110,12 @@ public class Namespace {
else if (o2 instanceof CharSequence)
n[i++] = create(o2.toString());
else
- throw new
BasicRuntimeException("Invalid type passed to NamespaceFactory.createArray:
''{0}''", o);
+ throw runtimeException("Invalid type
passed to NamespaceFactory.createArray: ''{0}''", cn(o));
}
return n;
}
- throw new BasicRuntimeException("Invalid type passed to
NamespaceFactory.createArray: ''{0}''", o);
+ throw runtimeException("Invalid type passed to
NamespaceFactory.createArray: ''{0}''", cn(o));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 79ea81d3f0..cdc8ec5635 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -19,6 +19,7 @@ package org.apache.juneau.xml;
import static javax.xml.stream.XMLStreamConstants.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.StringUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
@@ -248,7 +249,7 @@ public class XmlParserSession extends ReaderParserSession {
private String getElementAsString(XmlReader r) {
int t = r.getEventType();
if (t > 2)
- throw new BasicRuntimeException("Invalid event type on
stream reader for elementToString() method: ''{0}''",
XmlUtils.toReadableEvent(r));
+ throw runtimeException("Invalid event type on stream
reader for elementToString() method: ''{0}''", XmlUtils.toReadableEvent(r));
rsb.setLength(0);
rsb.append("<").append(t == 1 ? "" :
"/").append(r.getLocalName());
if (t == 1)
diff --git
a/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/ContentComboTestBase.java
b/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/ContentComboTestBase.java
index 1bc8161aea..57c34e43c9 100644
---
a/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/ContentComboTestBase.java
+++
b/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/ContentComboTestBase.java
@@ -17,6 +17,7 @@
package org.apache.juneau.examples.rest;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.examples.rest.TestUtils.*;
import static org.junit.runners.MethodSorters.*;
@@ -55,7 +56,7 @@ public class ContentComboTestBase extends RestTestcase {
case "text/uon" -> getClient(mt, UonSerializer.DEFAULT,
UonParser.DEFAULT);
case "application/x-www-form-urlencoded" ->
getClient(mt, UrlEncodingSerializer.DEFAULT, UrlEncodingParser.DEFAULT);
case "text/xml" -> getClient(mt, XmlSerializer.DEFAULT,
XmlParser.DEFAULT);
- default -> throw new BasicRuntimeException("Client for
mediaType ''{0}'' not found", mt);
+ default -> throw runtimeException("Client for mediaType
''{0}'' not found", mt);
};
}
diff --git
a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
index 2635eaa1df..12f0a5dd3c 100755
---
a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
+++
b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
@@ -17,6 +17,7 @@
package org.apache.juneau.microservice;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.FileUtils.*;
import static org.apache.juneau.common.utils.IOUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
@@ -29,7 +30,6 @@ import java.util.concurrent.*;
import java.util.jar.*;
import java.util.logging.*;
-import org.apache.juneau.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.reflect.*;
import org.apache.juneau.config.*;
@@ -425,7 +425,7 @@ public class Microservice implements ConfigEventListener {
else if (value instanceof Class clazz)
this.manifest = new ManifestFile(clazz);
else
- throw new BasicRuntimeException("Invalid type
passed to Builder.manifest(Object). Type=[{0}]", cn(value));
+ throw runtimeException("Invalid type passed to
Builder.manifest(Object). Type=[{0}]", cn(value));
return this;
}
diff --git
a/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
b/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
index 34a5d3d2f4..5f0e2e3a43 100644
---
a/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
+++
b/juneau-microservice/juneau-microservice-jetty/src/main/java/org/apache/juneau/microservice/jetty/JettyMicroservice.java
@@ -29,7 +29,6 @@ import java.nio.file.*;
import java.util.*;
import java.util.logging.*;
-import org.apache.juneau.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.reflect.*;
import org.apache.juneau.config.*;
@@ -217,7 +216,7 @@ public class JettyMicroservice extends Microservice {
else if (jettyXml instanceof Reader reader)
this.jettyXml = read(reader);
else
- throw new BasicRuntimeException("Invalid object
type passed to jettyXml(Object): {0}", cn(jettyXml));
+ throw runtimeException("Invalid object type
passed to jettyXml(Object): {0}", cn(jettyXml));
this.jettyXmlResolveVars = resolveVars;
return this;
}
@@ -558,7 +557,7 @@ public class JettyMicroservice extends Microservice {
if (jettyXml == null)
jettyXml = loadSystemResourceAsString("jetty.xml", ".",
"files");
if (jettyXml == null)
- throw new BasicRuntimeException("jetty.xml file ''{0}''
was not found on the file system or classpath.", jettyConfig);
+ throw runtimeException("jetty.xml file ''{0}'' was not
found on the file system or classpath.", jettyConfig);
if (resolveVars)
jettyXml = vr.resolve(jettyXml);
@@ -578,7 +577,7 @@ public class JettyMicroservice extends Microservice {
RestServlet rs =
(RestServlet)c.newInstance();
addServlet(rs, rs.getPath());
} else {
- throw new
BasicRuntimeException("Invalid servlet specified in Jetty/servlets. Must be a
subclass of RestServlet: {0}", s);
+ throw runtimeException("Invalid servlet
specified in Jetty/servlets. Must be a subclass of RestServlet: {0}", s);
}
} catch (ClassNotFoundException e1) {
throw new ExecutableException(e1);
@@ -592,7 +591,7 @@ public class JettyMicroservice extends Microservice {
Servlet rs = (Servlet)c.newInstance();
addServlet(rs, k);
} else {
- throw new
BasicRuntimeException("Invalid servlet specified in Jetty/servletMap. Must be
a subclass of Servlet: {0}", v);
+ throw runtimeException("Invalid servlet
specified in Jetty/servletMap. Must be a subclass of Servlet: {0}", cn(v));
}
} catch (ClassNotFoundException e1) {
throw new ExecutableException(e1);
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
index 2e2a4823a7..7851584f48 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/ResponseHeader.java
@@ -108,7 +108,7 @@ public class ResponseHeader extends BasicHeader {
try {
return opt(parser.parse(HEADER, schema, getValue(),
type));
} catch (ParseException e) {
- throw new BasicRuntimeException(e, "Could not parse
response header {0}.", getName());
+ throw runtimeException(e, "Could not parse response
header {0}.", getName());
}
}
@@ -264,7 +264,7 @@ public class ResponseHeader extends BasicHeader {
e = e.getCause();
throw toRuntimeException(e);
}
- throw new BasicRuntimeException("Could not determine a method
to construct type {0}", cn(c));
+ throw runtimeException("Could not determine a method to
construct type {0}", cn(c));
}
/**
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 94836e0730..845df2982a 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -4600,7 +4600,7 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
if (isEmpty(s))
rootUrl = null;
else if (s.indexOf("://") == -1)
- throw new BasicRuntimeException("Invalid
rootUrl value: ''{0}''. Must be a valid absolute URL.", value);
+ throw runtimeException("Invalid rootUrl value:
''{0}''. Must be a valid absolute URL.", value);
else
rootUrl = s;
return this;
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
index fdb3f2d7d0..c1f9f42d03 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java
@@ -19,6 +19,7 @@ package org.apache.juneau.rest.client;
import static java.util.stream.Collectors.toList;
import static org.apache.juneau.collections.JsonMap.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.IOUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.http.HttpEntities.*;
@@ -1648,7 +1649,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
q = s(value); // Works for NameValuePairs.
uriBuilder.setCustomQuery(q);
} catch (IOException e) {
- throw new BasicRuntimeException(e, "Could not read
custom query.");
+ throw runtimeException(e, "Could not read custom
query.");
}
return this;
}
@@ -2515,7 +2516,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
} else if (isBean(value)) {
toBeanMap(value).forEach((k, v) ->
l.add(createHeader(k, v, serializer, schema, skipIfEmpty)));
} else if (nn(value)) {
- throw new BasicRuntimeException("Invalid value type for
header arg ''{0}'': {1}", name, cn(value));
+ throw runtimeException("Invalid value type for header
arg ''{0}'': {1}", name, cn(value));
}
if (skipIfEmpty)
@@ -2550,7 +2551,7 @@ public class RestRequest extends BeanSession implements
HttpUriRequest, Configur
} else if (isBean(value)) {
toBeanMap(value).forEach((k, v) -> l.add(createPart(k,
v, PATH, serializer, schema, false)));
} else if (nn(value)) {
- throw new BasicRuntimeException("Invalid value type for
path arg ''{0}'': {1}", name, cn(value));
+ throw runtimeException("Invalid value type for path arg
''{0}'': {1}", name, cn(value));
}
pathData.append(l);
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
index 67a6ec0cd8..b0983c7296 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
@@ -17,6 +17,7 @@
package org.apache.juneau.rest.client.remote;
import static org.apache.juneau.common.utils.ClassUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
@@ -24,7 +25,6 @@ import static
org.apache.juneau.common.utils.CollectionUtils.*;
import java.lang.reflect.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.utils.*;
import org.apache.juneau.http.header.*;
import org.apache.juneau.http.remote.*;
@@ -81,7 +81,7 @@ public class RemoteMeta {
try {
headers.append(r.headerList().getDeclaredConstructor().newInstance().getAll());
} catch (Exception e) {
- throw new BasicRuntimeException(e,
"Could not instantiate HeaderSupplier class");
+ throw runtimeException(e, "Could not
instantiate HeaderSupplier class");
}
}
}
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpHeaders.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpHeaders.java
index 28bc40e974..a1c8038753 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpHeaders.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpHeaders.java
@@ -17,6 +17,7 @@
package org.apache.juneau.http;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.net.*;
import java.time.*;
@@ -526,7 +527,7 @@ public class HttpHeaders {
Map.Entry e = (Map.Entry)o;
return BasicHeader.of(s(e.getKey()), s(e.getValue()));
}
- throw new BasicRuntimeException("Object of type {0} could not
be converted to a Header.", cn(o));
+ throw runtimeException("Object of type {0} could not be
converted to a Header.", cn(o));
}
/**
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpParts.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpParts.java
index b3cecea85e..93a7bae48c 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpParts.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpParts.java
@@ -17,6 +17,7 @@
package org.apache.juneau.http;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.net.*;
import java.time.*;
@@ -180,7 +181,7 @@ public class HttpParts {
Map.Entry e = (Map.Entry)o;
return BasicPart.of(s(e.getKey()), e.getValue());
}
- throw new BasicRuntimeException("Object of type {0} could not
be converted to a Part.", o == null ? null : o.getClass().getName());
+ throw runtimeException("Object of type {0} could not be
converted to a Part.", cn(o));
}
/**
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/SerializedEntity.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/SerializedEntity.java
index fdb6293a11..ae91128a77 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/SerializedEntity.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/SerializedEntity.java
@@ -26,7 +26,6 @@ import java.nio.charset.*;
import java.util.function.*;
import org.apache.http.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.io.*;
import org.apache.juneau.http.header.*;
import org.apache.juneau.httppart.*;
@@ -255,7 +254,7 @@ public class SerializedEntity extends BasicHttpEntity {
}
}
} catch (SerializeException e) {
- throw new BasicRuntimeException(e, "Serialization error
on request body.");
+ throw runtimeException(e, "Serialization error on
request body.");
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
index 7bd20be25a..9a5cd1eb40 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
@@ -17,11 +17,11 @@
package org.apache.juneau.http.header;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.util.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.assertions.*;
import org.apache.juneau.http.annotation.*;
@@ -203,7 +203,7 @@ public class BasicIntegerHeader extends BasicHeader {
try {
return value == null ? null : Integer.parseInt(value);
} catch (NumberFormatException e) {
- throw new BasicRuntimeException(e, "Value ''{0}'' could
not be parsed as an integer.", value);
+ throw runtimeException(e, "Value ''{0}'' could not be
parsed as an integer.", value);
}
}
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
index f13fc5df02..b29cbb487d 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
@@ -17,11 +17,11 @@
package org.apache.juneau.http.header;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.util.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.assertions.*;
import org.apache.juneau.http.annotation.*;
@@ -204,7 +204,7 @@ public class BasicLongHeader extends BasicHeader {
try {
return value == null ? null : Long.parseLong(value);
} catch (NumberFormatException e) {
- throw new BasicRuntimeException(e, "Value ''{0}'' could
not be parsed as a long.", value);
+ throw runtimeException(e, "Value ''{0}'' could not be
parsed as a long.", value);
}
}
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/IfRange.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/IfRange.java
index 7540d27bdb..42c7d8f16e 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/IfRange.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/IfRange.java
@@ -18,12 +18,12 @@ package org.apache.juneau.http.header;
import static java.time.format.DateTimeFormatter.*;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.time.*;
import java.util.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
/**
@@ -220,7 +220,7 @@ public class IfRange extends BasicDateHeader {
} else if (o instanceof ZonedDateTime) {
return
RFC_1123_DATE_TIME.format((ZonedDateTime)o);
}
- throw new BasicRuntimeException("Invalid object type
returned by supplier: {0}", cn(o));
+ throw runtimeException("Invalid object type returned by
supplier: {0}", cn(o));
}
if (nn(value))
return s(value);
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/RetryAfter.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/RetryAfter.java
index b0e6cf810f..077397abd6 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/RetryAfter.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/RetryAfter.java
@@ -18,13 +18,13 @@ package org.apache.juneau.http.header;
import static java.time.format.DateTimeFormatter.*;
import static org.apache.juneau.common.utils.StringUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.time.*;
import java.util.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
/**
@@ -212,7 +212,7 @@ public class RetryAfter extends BasicDateHeader {
} else if (o instanceof ZonedDateTime) {
return
RFC_1123_DATE_TIME.format((ZonedDateTime)o);
}
- throw new BasicRuntimeException("Invalid object type
returned by supplier: {0}", cn(o));
+ throw runtimeException("Invalid object type returned by
supplier: {0}", cn(o));
}
if (nn(value))
return s(value);
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/SerializedHeader.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/SerializedHeader.java
index 782bc93f3f..589fe0cc5f 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/SerializedHeader.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/SerializedHeader.java
@@ -17,10 +17,10 @@
package org.apache.juneau.http.header;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.util.function.*;
-import org.apache.juneau.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.oapi.*;
import org.apache.juneau.serializer.*;
@@ -234,9 +234,9 @@ public class SerializedHeader extends BasicHeader {
return null;
return serializer == null ? s(v) :
serializer.serialize(HttpPartType.HEADER, schema, v);
} catch (SchemaValidationException e) {
- throw new BasicRuntimeException(e, "Validation error on
request {0} parameter ''{1}''=''{2}''", HttpPartType.HEADER, getName(), value);
+ throw runtimeException(e, "Validation error on request
{0} parameter ''{1}''=''{2}''", HttpPartType.HEADER, getName(), value);
} catch (SerializeException e) {
- throw new BasicRuntimeException(e, "Serialization error
on request {0} parameter ''{1}''", HttpPartType.HEADER, getName());
+ throw runtimeException(e, "Serialization error on
request {0} parameter ''{1}''", HttpPartType.HEADER, getName());
}
}
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/BasicPart.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/BasicPart.java
index 274f6e50ff..f40b375404 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/BasicPart.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/BasicPart.java
@@ -17,13 +17,13 @@
package org.apache.juneau.http.part;
import static org.apache.juneau.common.utils.AssertionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.util.*;
import java.util.function.*;
import org.apache.http.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.assertions.*;
import org.apache.juneau.http.header.*;
@@ -86,7 +86,7 @@ public class BasicPart implements NameValuePair, Headerable {
Map.Entry e = (Map.Entry)o;
return BasicPart.of(s(e.getKey()), e.getValue());
}
- throw new BasicRuntimeException("Object of type {0} could not
be converted to a Part.", cn(o));
+ throw runtimeException("Object of type {0} could not be
converted to a Part.", cn(o));
}
/**
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/SerializedPart.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/SerializedPart.java
index a8581d2e11..13341813cf 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/SerializedPart.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/SerializedPart.java
@@ -17,11 +17,11 @@
package org.apache.juneau.http.part;
import static org.apache.juneau.common.utils.Utils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import java.util.function.*;
import org.apache.http.*;
-import org.apache.juneau.*;
import org.apache.juneau.http.header.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.oapi.*;
@@ -165,9 +165,9 @@ public class SerializedPart extends BasicPart {
return null;
return serializer == null ? s(v) :
serializer.serialize(type, schema, v);
} catch (SchemaValidationException e) {
- throw new BasicRuntimeException(e, "Validation error on
request {0} part ''{1}''=''{2}''", type, getName(), value);
+ throw runtimeException(e, "Validation error on request
{0} part ''{1}''=''{2}''", type, getName(), value);
} catch (SerializeException e) {
- throw new BasicRuntimeException(e, "Serialization error
on request {0} part ''{1}''", type, getName());
+ throw runtimeException(e, "Serialization error on
request {0} part ''{1}''", type, getName());
}
}
diff --git
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
index 1f9ee70176..34ff2856a1 100644
---
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
+++
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
@@ -17,11 +17,11 @@
package org.apache.juneau.rest.mock;
import static org.apache.juneau.common.utils.StateEnum.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import java.util.*;
-import org.apache.juneau.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.utils.*;
import org.apache.juneau.rest.util.*;
@@ -220,19 +220,19 @@ class MockPathResolver {
} else if (state == S7) {
this.remainder = uri.substring(mark);
} else {
- throw new BasicRuntimeException("Invalid URI pattern
encountered: {0}", uri);
+ throw runtimeException("Invalid URI pattern
encountered: {0}", uri);
}
if (! contextPath.isEmpty()) {
UrlPathMatcher p = UrlPathMatcher.of(contextPath);
if (p.match(UrlPath.of(this.contextPath)) == null)
- throw new BasicRuntimeException("Context path
[{0}] not found in URI: {1}", contextPath, uri);
+ throw runtimeException("Context path [{0}] not
found in URI: {1}", contextPath, uri);
}
if (! servletPath.isEmpty()) {
UrlPathMatcher p = UrlPathMatcher.of(servletPath);
if (p.match(UrlPath.of(this.servletPath)) == null)
- throw new BasicRuntimeException("Servlet path
[{0}] not found in URI: {1}", servletPath, uri);
+ throw runtimeException("Servlet path [{0}] not
found in URI: {1}", servletPath, uri);
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
index 584e98a08f..84570d3f70 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
@@ -16,6 +16,9 @@
*/
package org.apache.juneau.rest.beans;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
+import static org.apache.juneau.common.utils.Utils.*;
+
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -84,7 +87,7 @@ public class BeanDescription {
type = c.getName();
BeanMeta<?> bm = BeanContext.DEFAULT.getBeanMeta(c);
if (bm == null)
- throw new BasicRuntimeException("Class ''{0}'' is not a
valid bean.", c);
+ throw runtimeException("Class ''{0}'' is not a valid
bean.", cn(c));
properties = new
BeanPropertyDescription[bm.getPropertyMetas().size()];
int i = 0;
for (BeanPropertyMeta pm : bm.getPropertyMetas())
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeaders.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeaders.java
index 3b4d0841a9..8d8b6ab4dc 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeaders.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeaders.java
@@ -19,6 +19,7 @@ package org.apache.juneau.rest.httppart;
import static java.util.stream.Collectors.toList;
import static org.apache.juneau.common.utils.AssertionUtils.*;
import static org.apache.juneau.common.utils.CollectionUtils.*;
+import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.httppart.HttpPartType.*;
@@ -311,7 +312,7 @@ public class RequestHeaders extends
ArrayList<RequestHeader> {
*/
public <T> Optional<T> get(Class<T> type) {
ClassMeta<T> cm = req.getBeanSession().getClassMeta(type);
- String name = HttpParts.getName(HEADER, cm).orElseThrow(() ->
new BasicRuntimeException("@Header(name) not found on class {0}", cn(type)));
+ String name = HttpParts.getName(HEADER, cm).orElseThrow(() ->
runtimeException("@Header(name) not found on class {0}", cn(type)));
return get(name).as(type);
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
index 0f2ef0386c..72601f7f08 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/util/RestUtils.java
@@ -27,7 +27,6 @@ import java.io.*;
import java.util.*;
import java.util.regex.*;
-import org.apache.juneau.*;
import org.apache.juneau.common.utils.*;
import org.apache.juneau.json.*;
import org.apache.juneau.parser.*;
@@ -445,7 +444,7 @@ public class RestUtils {
return requestURI;
throw new Exception("case=6");
} catch (Exception e) {
- throw new BasicRuntimeException(e, "Could not find
servlet path in request URI. URI=''{0}'', servletPath=''{1}''", requestURI,
servletPath);
+ throw runtimeException(e, "Could not find servlet path
in request URI. URI=''{0}'', servletPath=''{1}''", requestURI, servletPath);
}
}
@@ -456,7 +455,7 @@ public class RestUtils {
*/
public static void validateContextPath(String value) {
if (! isValidContextPath(value))
- throw new BasicRuntimeException("Value is not a valid
context path: [{0}]", value);
+ throw runtimeException("Value is not a valid context
path: [{0}]", value);
}
/**
@@ -466,7 +465,7 @@ public class RestUtils {
*/
public static void validatePathInfo(String value) {
if (! isValidPathInfo(value))
- throw new BasicRuntimeException("Value is not a valid
path-info path: [{0}]", value);
+ throw runtimeException("Value is not a valid path-info
path: [{0}]", value);
}
/**
@@ -476,7 +475,7 @@ public class RestUtils {
*/
public static void validateServletPath(String value) {
if (! isValidServletPath(value))
- throw new BasicRuntimeException("Value is not a valid
servlet path: [{0}]", value);
+ throw runtimeException("Value is not a valid servlet
path: [{0}]", value);
}
private static void add(Map<String,String[]> m, String key, String val)
{
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/assertions/Assertion_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/assertions/Assertion_Test.java
index 50eb591ea0..0ac4d50ff6 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/assertions/Assertion_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/assertions/Assertion_Test.java
@@ -72,7 +72,7 @@ class Assertion_Test extends TestBase {
a.setThrowable(A3.class);
assertThrown(a::doError)
- .isExactType(BasicRuntimeException.class)
+ .isExactType(RuntimeException.class)
.asMessage().is("bar baz")
.asCausedBy().isExactType(A1.class)
.asCausedBy().asMessage().is("foo")
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/bean/openapi3/OpenApi_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/bean/openapi3/OpenApi_Test.java
index 3ddc7bb597..98bbed2d36 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/bean/openapi3/OpenApi_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/bean/openapi3/OpenApi_Test.java
@@ -309,7 +309,7 @@ class OpenApi_Test extends TestBase {
assertThrows(IllegalArgumentException.class, () ->
x.findRef(null, SchemaInfo.class));
assertThrows(IllegalArgumentException.class, () ->
x.findRef("a", null));
assertThrows(IllegalArgumentException.class, () ->
x.findRef("", SchemaInfo.class));
- assertThrowsWithMessage(BasicRuntimeException.class,
"Unsupported reference: 'invalid'", () -> x.findRef("invalid",
SchemaInfo.class));
+ assertThrowsWithMessage(RuntimeException.class,
"Unsupported reference: 'invalid'", () -> x.findRef("invalid",
SchemaInfo.class));
}
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/SwaggerBuilder_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/SwaggerBuilder_Test.java
index 3565a1e052..00551979ca 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/SwaggerBuilder_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/SwaggerBuilder_Test.java
@@ -59,7 +59,7 @@ class SwaggerBuilder_Test extends TestBase {
t = headerInfoStrict("string");
assertJson("{type:'string'}", t);
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
value passed in to setType(String). Value='foo', valid
values=['string','number','integer','boolean','array']",
()->headerInfoStrict("foo"));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid value
passed in to setType(String). Value='foo', valid
values=['string','number','integer','boolean','array']",
()->headerInfoStrict("foo"));
}
@Test void a04_info() {
@@ -79,7 +79,7 @@ class SwaggerBuilder_Test extends TestBase {
t = itemsStrict("string");
assertJson("{type:'string'}", t);
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
value passed in to setType(String). Value='foo', valid
values=['string','number','integer','boolean','array']",
()->itemsStrict("foo"));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid value
passed in to setType(String). Value='foo', valid
values=['string','number','integer','boolean','array']",
()->itemsStrict("foo"));
}
@Test void a06_license() {
@@ -104,7 +104,7 @@ class SwaggerBuilder_Test extends TestBase {
t = parameterInfoStrict("query", "bar");
assertJson("{'in':'query',name:'bar'}", t);
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
value passed in to setIn(String). Value='foo', valid
values=['query','header','path','formData','body']",
()->parameterInfoStrict("foo", "bar"));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid value
passed in to setIn(String). Value='foo', valid
values=['query','header','path','formData','body']",
()->parameterInfoStrict("foo", "bar"));
}
@Test void a09_responseInfo() {
@@ -176,12 +176,12 @@ class SwaggerBuilder_Test extends TestBase {
@Test void a18_itemsStrict() {
var t = itemsStrict("string");
assertJson("{type:'string'}", t);
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
value passed in to setType(String). Value='foo', valid
values=['string','number','integer','boolean','array']",
()->itemsStrict("foo"));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid value
passed in to setType(String). Value='foo', valid
values=['string','number','integer','boolean','array']",
()->itemsStrict("foo"));
}
@Test void a19_securitySchemeStrict() {
var t = securitySchemeStrict("basic");
assertJson("{type:'basic'}", t);
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
value passed in to setType(String). Value='foo', valid
values=['basic','apiKey','oauth2']", ()->securitySchemeStrict("foo"));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid value
passed in to setType(String). Value='foo', valid
values=['basic','apiKey','oauth2']", ()->securitySchemeStrict("foo"));
}
}
\ No newline at end of file
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/Swagger_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/Swagger_Test.java
index 670d88a6de..8204ffd16a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/Swagger_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/bean/swagger/Swagger_Test.java
@@ -430,7 +430,7 @@ class Swagger_Test extends TestBase {
assertThrows(IllegalArgumentException.class, () ->
x.findRef(null, JsonMap.class));
assertThrows(IllegalArgumentException.class, () ->
x.findRef("a", null));
assertThrows(IllegalArgumentException.class, () ->
x.findRef("", JsonMap.class));
- assertThrowsWithMessage(BasicRuntimeException.class,
"Unsupported reference: 'invalid'", () -> x.findRef("invalid", JsonMap.class));
+ assertThrowsWithMessage(RuntimeException.class,
"Unsupported reference: 'invalid'", () -> x.findRef("invalid", JsonMap.class));
}
@Test void d02_findRefInvalidType() {
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/common/utils/ThrowableUtils_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/common/utils/ThrowableUtils_Test.java
index 994d860f5d..277cae57f6 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/common/utils/ThrowableUtils_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/common/utils/ThrowableUtils_Test.java
@@ -20,6 +20,8 @@ import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import java.io.*;
+import java.net.*;
+import java.sql.*;
import org.apache.juneau.*;
import org.junit.jupiter.api.*;
@@ -77,5 +79,143 @@ class ThrowableUtils_Test extends TestBase {
assertTrue(findCause(cause,
IllegalStateException.class).isPresent());
assertEquals("root", findCause(cause,
IllegalStateException.class).get().getMessage());
}
+
+
//====================================================================================================
+ // unsupportedOp(String, Object...)
+
//====================================================================================================
+ @Test
+ void b01_unsupportedOp_noArgs() {
+ UnsupportedOperationException ex = unsupportedOp("Operation not
supported");
+ assertEquals("Operation not supported", ex.getMessage());
+ assertInstanceOf(UnsupportedOperationException.class, ex);
+ }
+
+ @Test
+ void b02_unsupportedOp_withArgs() {
+ UnsupportedOperationException ex = unsupportedOp("Operation {0}
is not supported for type {1}", "delete", "User");
+ assertEquals("Operation delete is not supported for type User",
ex.getMessage());
+ }
+
+ @Test
+ void b03_unsupportedOp_emptyArgs() {
+ UnsupportedOperationException ex = unsupportedOp("No
formatting");
+ assertEquals("No formatting", ex.getMessage());
+ }
+
+ @Test
+ void b04_unsupportedOp_throwable() {
+ UnsupportedOperationException ex = unsupportedOp("Cannot modify
{0}", "immutable list");
+ assertThrows(UnsupportedOperationException.class, () -> {
+ throw ex;
+ });
+ }
+
+
//====================================================================================================
+ // ioException(String, Object...)
+
//====================================================================================================
+ @Test
+ void c01_ioException_noArgs() {
+ IOException ex = ioException("File not found");
+ assertEquals("File not found", ex.getMessage());
+ assertInstanceOf(IOException.class, ex);
+ }
+
+ @Test
+ void c02_ioException_withArgs() {
+ IOException ex = ioException("Failed to read file {0} at line
{1}", "/tmp/test.txt", 42);
+ assertEquals("Failed to read file /tmp/test.txt at line 42",
ex.getMessage());
+ }
+
+ @Test
+ void c03_ioException_emptyArgs() {
+ IOException ex = ioException("No formatting");
+ assertEquals("No formatting", ex.getMessage());
+ }
+
+ @Test
+ void c04_ioException_throwable() {
+ IOException ex = ioException("Cannot write to {0}",
"readonly.txt");
+ assertThrows(IOException.class, () -> {
+ throw ex;
+ });
+ }
+
+ @Test
+ void c05_ioException_multipleArgs() {
+ IOException ex = ioException("Error at position {0}:{1} in file
{2}", 10, 25, "data.csv");
+ assertEquals("Error at position 10:25 in file data.csv",
ex.getMessage());
+ }
+
+
//====================================================================================================
+ // Exception methods with causes
+
//====================================================================================================
+ @Test
+ void d01_illegalArg_withCause() {
+ IOException cause = new IOException("root cause");
+ IllegalArgumentException ex = illegalArg(cause, "Invalid
parameter {0}", "userId");
+
+ assertEquals("Invalid parameter userId", ex.getMessage());
+ assertSame(cause, ex.getCause());
+ assertEquals("root cause", ex.getCause().getMessage());
+ }
+
+ @Test
+ void d02_runtimeException_withCause() {
+ SQLException cause = new SQLException("Database error");
+ RuntimeException ex = runtimeException(cause, "Failed to
process {0} at {1}", "user", "login");
+
+ assertEquals("Failed to process user at login",
ex.getMessage());
+ assertSame(cause, ex.getCause());
+ assertEquals("Database error", ex.getCause().getMessage());
+ }
+
+ @Test
+ void d03_unsupportedOp_withCause() {
+ IllegalStateException cause = new
IllegalStateException("Locked");
+ UnsupportedOperationException ex = unsupportedOp(cause, "Cannot
{0} on {1}", "delete", "immutable collection");
+
+ assertEquals("Cannot delete on immutable collection",
ex.getMessage());
+ assertSame(cause, ex.getCause());
+ assertEquals("Locked", ex.getCause().getMessage());
+ }
+
+ @Test
+ void d04_ioException_withCause() {
+ FileNotFoundException cause = new
FileNotFoundException("config.xml");
+ IOException ex = ioException(cause, "Failed to load {0}",
"configuration");
+
+ assertEquals("Failed to load configuration", ex.getMessage());
+ assertSame(cause, ex.getCause());
+ assertEquals("config.xml", ex.getCause().getMessage());
+ }
+
+ @Test
+ void d05_runtimeException_withCause_noArgs() {
+ NullPointerException cause = new NullPointerException("value
was null");
+ RuntimeException ex = runtimeException(cause, "Processing
failed");
+
+ assertEquals("Processing failed", ex.getMessage());
+ assertSame(cause, ex.getCause());
+ }
+
+ @Test
+ void d06_ioException_withCause_multipleArgs() {
+ SocketException cause = new SocketException("Connection reset");
+ IOException ex = ioException(cause, "Network error at {0}:{1}
for host {2}", "192.168.1.1", "8080", "server");
+
+ assertEquals("Network error at 192.168.1.1:8080 for host
server", ex.getMessage());
+ assertSame(cause, ex.getCause());
+ }
+
+ @Test
+ void d07_exception_withCause_chaining() {
+ IOException rootCause = new IOException("disk full");
+ RuntimeException wrappedException = runtimeException(rootCause,
"Cannot write file {0}", "output.txt");
+ IllegalArgumentException topException =
illegalArg(wrappedException, "Invalid operation");
+
+ assertEquals("Invalid operation", topException.getMessage());
+ assertEquals("Cannot write file output.txt",
topException.getCause().getMessage());
+ assertEquals("disk full",
topException.getCause().getCause().getMessage());
+ }
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/BasicPart_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/BasicPart_Test.java
index f3071ba7ac..329e4a57a0 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/BasicPart_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/BasicPart_Test.java
@@ -81,8 +81,8 @@ class BasicPart_Test extends TestBase {
assertTypeAndJson(NameValuePair.class, "'X7=7'",
BasicPart.cast(x7));
assertTypeAndJson(NameValuePair.class, "'X8=8'",
BasicPart.cast(x8));
- assertThrowsWithMessage(BasicRuntimeException.class, "Object of
type java.lang.String could not be converted to a Part.",
()->BasicPart.cast("X"));
- assertThrowsWithMessage(BasicRuntimeException.class, "Object of
type null could not be converted to a Part.", ()->BasicPart.cast(null));
+ assertThrowsWithMessage(RuntimeException.class, "Object of type
java.lang.String could not be converted to a Part.", ()->BasicPart.cast("X"));
+ assertThrowsWithMessage(RuntimeException.class, "Object of type
null could not be converted to a Part.", ()->BasicPart.cast(null));
assertTrue(BasicPart.canCast(x1));
assertTrue(BasicPart.canCast(x2));
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/HttpHeaders_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/HttpHeaders_Test.java
index b14b3a18fc..91d00e4e27 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/HttpHeaders_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/HttpHeaders_Test.java
@@ -54,8 +54,8 @@ class HttpHeaders_Test extends TestBase {
assertTypeAndJson(Header.class, "'X8: 8'",
HttpHeaders.cast(x8));
assertTypeAndJson(Header.class, "'X9: 9'",
HttpHeaders.cast(x9));
- assertThrowsWithMessage(BasicRuntimeException.class, "Object of
type java.lang.String could not be converted to a Header.",
()->HttpHeaders.cast("X"));
- assertThrowsWithMessage(BasicRuntimeException.class, "Object of
type null could not be converted to a Header.", ()->HttpHeaders.cast(null));
+ assertThrowsWithMessage(RuntimeException.class, "Object of type
java.lang.String could not be converted to a Header.",
()->HttpHeaders.cast("X"));
+ assertThrowsWithMessage(RuntimeException.class, "Object of type
null could not be converted to a Header.", ()->HttpHeaders.cast(null));
assertTrue(HttpHeaders.canCast(x1));
assertTrue(HttpHeaders.canCast(x2));
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHeader_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHeader_Test.java
index a0fb2ab090..64e1d6eb43 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHeader_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHeader_Test.java
@@ -43,7 +43,7 @@ class SerializedHeader_Test extends TestBase {
@Test void a02_type() {
var x1 =
serializedHeader("Foo",2).serializer(OAPI_SERIALIZER).schema(schema(INTEGER).maximum(1).build());
- assertThrowsWithMessage(BasicRuntimeException.class,
"Validation error on request HEADER parameter 'Foo'='2'", x1::toString);
+ assertThrowsWithMessage(RuntimeException.class, "Validation
error on request HEADER parameter 'Foo'='2'", x1::toString);
}
@Test void a03_serializer() {
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/SerializedPart_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/SerializedPart_Test.java
index b8f272e5a6..a9269dd702 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/SerializedPart_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/SerializedPart_Test.java
@@ -44,7 +44,7 @@ class SerializedPart_Test extends TestBase {
@Test void a02_type() {
var x1 =
serializedPart("Foo",2).type(HEADER).serializer(OAPI_SERIALIZER).schema(schema(INTEGER).maximum(1).build());
- assertThrowsWithMessage(BasicRuntimeException.class,
"Validation error on request HEADER part 'Foo'='2'", x1::toString);
+ assertThrowsWithMessage(RuntimeException.class, "Validation
error on request HEADER part 'Foo'='2'", x1::toString);
}
@Test void a03_serializer() {
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicIntegerHeader_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicIntegerHeader_Test.java
index f94ec09d6b..2f79641939 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicIntegerHeader_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicIntegerHeader_Test.java
@@ -61,7 +61,7 @@ class BasicIntegerHeader_Test extends TestBase {
// Invalid usage.
c.get().header(integerHeader(HEADER,(Supplier<Integer>)null)).run().assertContent().isEmpty();
- assertThrowsWithMessage(BasicRuntimeException.class, "Value
'foo' could not be parsed as an integer.", ()->integerHeader(HEADER,"foo"));
+ assertThrowsWithMessage(RuntimeException.class, "Value 'foo'
could not be parsed as an integer.", ()->integerHeader(HEADER,"foo"));
assertThrowsWithMessage(IllegalArgumentException.class, "Name
cannot be empty on header.", ()->integerHeader("", VALUE));
assertThrowsWithMessage(IllegalArgumentException.class, "Name
cannot be empty on header.", ()->integerHeader(null, VALUE));
assertThrowsWithMessage(IllegalArgumentException.class, "Name
cannot be empty on header.", ()->integerHeader("", PARSED));
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicLongHeader_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicLongHeader_Test.java
index d215ef6a93..1afa90ef3b 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicLongHeader_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/http/header/BasicLongHeader_Test.java
@@ -60,7 +60,7 @@ class BasicLongHeader_Test extends TestBase {
// Invalid usage.
c.get().header(longHeader(HEADER,(Supplier<Long>)null)).run().assertContent().isEmpty();
- assertThrowsWithMessage(BasicRuntimeException.class, "Value
'foo' could not be parsed as a long.", ()->longHeader(HEADER,"foo"));
+ assertThrowsWithMessage(RuntimeException.class, "Value 'foo'
could not be parsed as a long.", ()->longHeader(HEADER,"foo"));
assertThrowsWithMessage(IllegalArgumentException.class, "Name
cannot be empty on header.", ()->longHeader("", VALUE));
assertThrowsWithMessage(IllegalArgumentException.class, "Name
cannot be empty on header.", ()->longHeader(null, VALUE));
assertThrowsWithMessage(IllegalArgumentException.class, "Name
cannot be empty on header.", ()->longHeader("", PARSED));
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
index 88695019f3..44829774e1 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfo_Test.java
@@ -374,7 +374,7 @@ class ExecutableInfo_Test extends TestBase {
}
@Test void isAll_invalidFlag() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
flag for executable: TRANSIENT", ()->e_deprecated.isAll(TRANSIENT));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid flag
for executable: TRANSIENT", ()->e_deprecated.isAll(TRANSIENT));
}
@Test void isAny() {
@@ -402,7 +402,7 @@ class ExecutableInfo_Test extends TestBase {
}
@Test void isAny_invalidFlag() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
flag for executable: TRANSIENT", ()->e_deprecated.isAny(TRANSIENT));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid flag
for executable: TRANSIENT", ()->e_deprecated.isAny(TRANSIENT));
}
@Test void hasArgs() {
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfo_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfo_Test.java
index 0da13ecd7c..106ed8a5ba 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfo_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfo_Test.java
@@ -183,7 +183,7 @@ class FieldInfo_Test extends TestBase {
}
@Test void isAll_invalidFlag() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
flag for field: HAS_PARAMS", ()->c_deprecated.isAll(HAS_PARAMS));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid flag
for field: HAS_PARAMS", ()->c_deprecated.isAll(HAS_PARAMS));
}
@Test void isAny() {
@@ -207,7 +207,7 @@ class FieldInfo_Test extends TestBase {
}
@Test void isAny_invalidFlag() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
flag for field: HAS_PARAMS", ()->c_deprecated.isAny(HAS_PARAMS));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid flag
for field: HAS_PARAMS", ()->c_deprecated.isAny(HAS_PARAMS));
}
@Test void isDeprecated() {
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
b/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
index 5d71021a19..ceafc780d4 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
@@ -325,15 +325,15 @@ class ReflectionMapTest extends TestBase {
//------------------------------------------------------------------------------------------------------------------
@Test void e01_blankInput() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
reflection signature: []", ()->create().append("", 1));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid
reflection signature: []", ()->create().append("", 1));
}
@Test void e02_nullInput() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
reflection signature: [null]", ()->create().append(null, 1));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid
reflection signature: [null]", ()->create().append(null, 1));
}
@Test void e03_badInput() {
- assertThrowsWithMessage(BasicRuntimeException.class, "Invalid
reflection signature: [foo)]", ()->create().append("foo)", 1));
+ assertThrowsWithMessage(RuntimeException.class, "Invalid
reflection signature: [foo)]", ()->create().append("foo)", 1));
}
//------------------------------------------------------------------------------------------------------------------