Skip to content

Commit 8b8c3fa

Browse files
[refactor] Re-add expressionless XPathException constructor calls.
1 parent 4e52f37 commit 8b8c3fa

File tree

57 files changed

+197
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+197
-189
lines changed

exist-core/src/main/antlr/org/exist/xquery/parser/DeclScanner.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ versionDecl throws XPathException
8787
}
8888
)?
8989
{
90-
throw new XPathException((Expression) null, "Processing stopped");
90+
throw new XPathException("Processing stopped");
9191
}
9292
;

exist-core/src/main/java/org/exist/backup/xquery/ListBackups.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ListBackups(final XQueryContext context )
6363
public Sequence eval(final Sequence[] args, final Sequence contextSequence ) throws XPathException
6464
{
6565
if(!context.getEffectiveUser().hasDbaRole()) {
66-
throw new XPathException((Expression) null, "You must be a DBA to list available backups");
66+
throw new XPathException("You must be a DBA to list available backups");
6767
}
6868

6969
final String exportDir = args[0].getStringValue();

exist-core/src/main/java/org/exist/backup/xquery/RetrieveBackup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public RetrieveBackup(final XQueryContext context )
5656
public Sequence eval(final Sequence[] args, final Sequence contextSequence ) throws XPathException
5757
{
5858
if(!context.getEffectiveUser().hasDbaRole()) {
59-
throw new XPathException((Expression) null, "You must be a DBA to retrieve a backup");
59+
throw new XPathException("You must be a DBA to retrieve a backup");
6060
}
6161

6262
final String exportDir = args[0].getStringValue();

exist-core/src/main/java/org/exist/dom/memtree/NodeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,15 @@ public boolean equals(final NodeValue other) throws XPathException {
335335
@Override
336336
public boolean after(final NodeValue other, final boolean isFollowing) throws XPathException {
337337
if(other.getImplementationType() != NodeValue.IN_MEMORY_NODE) {
338-
throw new XPathException((Expression) null, "cannot compare persistent node with in-memory node");
338+
throw new XPathException("cannot compare persistent node with in-memory node");
339339
}
340340
return nodeNumber > ((NodeImpl) other).nodeNumber;
341341
}
342342

343343
@Override
344344
public boolean before(final NodeValue other, final boolean isPreceding) throws XPathException {
345345
if(other.getImplementationType() != NodeValue.IN_MEMORY_NODE) {
346-
throw new XPathException((Expression) null, "cannot compare persistent node with in-memory node");
346+
throw new XPathException("cannot compare persistent node with in-memory node");
347347
}
348348
return nodeNumber < ((NodeImpl)other).nodeNumber;
349349
}

exist-core/src/main/java/org/exist/dom/persistent/AbstractNodeSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public int getItemType() {
7878
@Override
7979
public void add(final Item item) throws XPathException {
8080
if(!Type.subTypeOf(item.getType(), Type.NODE)) {
81-
throw new XPathException((Expression) null, "item has wrong type");
81+
throw new XPathException("item has wrong type");
8282
}
8383
add((NodeProxy) item);
8484
}
@@ -106,7 +106,7 @@ public void add(final NodeProxy proxy, final int sizeHint) {
106106
@Override
107107
public void addAll(final Sequence other) throws XPathException {
108108
if(!other.isEmpty() && !Type.subTypeOf(other.getItemType(), Type.NODE)) {
109-
throw new XPathException((Expression) null, "sequence argument is not a node sequence");
109+
throw new XPathException("sequence argument is not a node sequence");
110110
}
111111
if(Type.subTypeOf(other.getItemType(), Type.NODE)) {
112112
addAll((NodeSet) other);

exist-core/src/main/java/org/exist/dom/persistent/NodeProxy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public boolean equals(final Object other) {
279279
@Override
280280
public boolean equals(final NodeValue other) throws XPathException {
281281
if(other.getImplementationType() != NodeValue.PERSISTENT_NODE) {
282-
throw new XPathException((Expression) null, "Cannot compare persistent node with in-memory node");
282+
throw new XPathException("Cannot compare persistent node with in-memory node");
283283
}
284284
final NodeProxy otherNode = (NodeProxy) other;
285285
if(otherNode.doc.getDocId() != doc.getDocId()) {
@@ -291,7 +291,7 @@ public boolean equals(final NodeValue other) throws XPathException {
291291
@Override
292292
public boolean before(final NodeValue other, final boolean isPreceding) throws XPathException {
293293
if(other.getImplementationType() != NodeValue.PERSISTENT_NODE) {
294-
throw new XPathException((Expression) null, "Cannot compare persistent node with in-memory node");
294+
throw new XPathException("Cannot compare persistent node with in-memory node");
295295
}
296296
final NodeProxy otherNode = (NodeProxy) other;
297297
if(doc.getDocId() != otherNode.doc.getDocId()) {
@@ -304,7 +304,7 @@ public boolean before(final NodeValue other, final boolean isPreceding) throws X
304304
@Override
305305
public boolean after(final NodeValue other, final boolean isFollowing) throws XPathException {
306306
if(other.getImplementationType() != NodeValue.PERSISTENT_NODE) {
307-
throw new XPathException((Expression) null, "Cannot compare persistent node with in-memory node");
307+
throw new XPathException("Cannot compare persistent node with in-memory node");
308308
}
309309
final NodeProxy otherNode = (NodeProxy) other;
310310
if(doc.getDocId() != otherNode.doc.getDocId()) {

exist-core/src/main/java/org/exist/http/RESTServer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle
311311
namespaces = nsExtractor.getNamespaces();
312312
}
313313
} catch (final SAXException e) {
314-
final XPathException x = new XPathException((Expression) null, e.toString());
314+
final XPathException x = new XPathException(e.toString());
315315
writeXPathException(response, HttpServletResponse.SC_BAD_REQUEST, UTF_8.name(), query, path, x);
316316
}
317317

@@ -421,9 +421,9 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle
421421
return;
422422
} catch (final LockException le) {
423423
if (MimeType.XML_TYPE.getName().equals(mimeType)) {
424-
writeXPathException(response, HttpServletResponse.SC_BAD_REQUEST, encoding, query, path, new XPathException((Expression) null, le.getMessage(), le));
424+
writeXPathException(response, HttpServletResponse.SC_BAD_REQUEST, encoding, query, path, new XPathException(le.getMessage(), le));
425425
} else {
426-
writeXPathExceptionHtml(response, HttpServletResponse.SC_BAD_REQUEST, encoding, query, path, new XPathException((Expression) null, le.getMessage(), le));
426+
writeXPathExceptionHtml(response, HttpServletResponse.SC_BAD_REQUEST, encoding, query, path, new XPathException(le.getMessage(), le));
427427
}
428428
}
429429

@@ -1483,7 +1483,7 @@ private void declareExternalAndXQJVariables(final XQueryContext context,
14831483
try {
14841484
sequence = value == null ? Sequence.EMPTY_SEQUENCE : Marshaller.demarshall(value);
14851485
} catch (final XMLStreamException xe) {
1486-
throw new XPathException((Expression) null, xe.toString());
1486+
throw new XPathException(xe.toString());
14871487
}
14881488

14891489
// now declare variable

exist-core/src/main/java/org/exist/repo/Deployment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public Optional<String> deploy(final DBBroker broker, final Txn transaction, fin
387387
// no target means: package does not need to be deployed into database
388388
// however, we need to preserve a copy for backup purposes
389389
final Optional<Package> pkg = getPackage(pkgName, repo);
390-
pkg.orElseThrow(() -> new XPathException((Expression) null, "expath repository is not available so the package was not stored."));
390+
pkg.orElseThrow(() -> new XPathException("expath repository is not available so the package was not stored."));
391391
final String pkgColl = pkg.get().getAbbrev() + "-" + pkg.get().getVersion();
392392
targetCollection = XmldbURI.SYSTEM.append("repo/" + pkgColl);
393393
}

exist-core/src/main/java/org/exist/repo/ExistRepository.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public Module resolveJavaModule(final String namespace, final XQueryContext ctxt
129129
uri = new URI(namespace);
130130
}
131131
catch (final URISyntaxException ex) {
132-
throw new XPathException(null, ErrorCodes.XQST0046, "Invalid URI: " + namespace, ex);
132+
throw new XPathException(ErrorCodes.XQST0046, "Invalid URI: " + namespace, ex);
133133
}
134134
for (final Packages pp : myParent.listPackages()) {
135135
final Package pkg = pp.latest();
@@ -155,17 +155,17 @@ private Module getModule(final String name, final String namespace, final XQuery
155155
final Module module = instantiateModule(clazz);
156156
final String ns = module.getNamespaceURI();
157157
if (!ns.equals(namespace)) {
158-
throw new XPathException((Expression) null, "The namespace in the Java module " +
158+
throw new XPathException("The namespace in the Java module " +
159159
"does not match the namespace in the package descriptor: " +
160160
namespace + " - " + ns);
161161
}
162162
return ctxt.loadBuiltInModule(namespace, name);
163163
} catch (final ClassNotFoundException ex) {
164-
throw new XPathException((Expression) null, "Cannot find module class from EXPath repository: " + name, ex);
164+
throw new XPathException("Cannot find module class from EXPath repository: " + name, ex);
165165
} catch (final ClassCastException ex) {
166-
throw new XPathException((Expression) null, "The class configured in EXPath repository is not a Module: " + name, ex);
166+
throw new XPathException("The class configured in EXPath repository is not a Module: " + name, ex);
167167
} catch (final IllegalArgumentException ex) {
168-
throw new XPathException((Expression) null, "Illegal argument passed to the module ctor", ex);
168+
throw new XPathException("Illegal argument passed to the module ctor", ex);
169169
}
170170
}
171171

@@ -196,7 +196,7 @@ private Module instantiateModule(final Class<Module> clazz) throws XPathExceptio
196196
// need to log here, otherwise details are swallowed by XQueryTreeParser
197197
LOG.error(e.getMessage(), e);
198198

199-
throw new XPathException((Expression) null, msg, e);
199+
throw new XPathException(msg, e);
200200
}
201201
}
202202

@@ -215,7 +215,7 @@ public Path resolveXQueryModule(final String namespace) throws XPathException {
215215
try {
216216
uri = new URI(namespace);
217217
} catch (final URISyntaxException ex) {
218-
throw new XPathException(null, ErrorCodes.XQST0046, "Invalid URI: " + namespace, ex);
218+
throw new XPathException(ErrorCodes.XQST0046, "Invalid URI: " + namespace, ex);
219219
}
220220
for (final Packages pp : myParent.listPackages()) {
221221
final Package pkg = pp.latest();
@@ -237,9 +237,9 @@ public Path resolveXQueryModule(final String namespace) throws XPathException {
237237
return Paths.get(new URI(sysid));
238238
}
239239
} catch (final URISyntaxException ex) {
240-
throw new XPathException(null, ErrorCodes.XQST0046, "Error parsing the URI of the query library: " + sysid, ex);
240+
throw new XPathException(ErrorCodes.XQST0046, "Error parsing the URI of the query library: " + sysid, ex);
241241
} catch (final PackageException ex) {
242-
throw new XPathException(null, ErrorCodes.XQST0059, "Error resolving the query library: " + namespace, ex);
242+
throw new XPathException(ErrorCodes.XQST0059, "Error resolving the query library: " + namespace, ex);
243243
} finally {
244244
if (src != null && src instanceof StreamSource) {
245245
final StreamSource streamSource = ((StreamSource)src);

exist-core/src/main/java/org/exist/security/PermissionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static void updatePermissions(final DBBroker broker, final Txn transacti
144144
try(final LockedDocument lockedDoc = broker.getXMLResource(pathUri, LockMode.WRITE_LOCK)) {
145145

146146
if (lockedDoc == null) {
147-
throw new XPathException((Expression) null, "Resource or collection '" + pathUri.toString() + "' does not exist.");
147+
throw new XPathException("Resource or collection '" + pathUri.toString() + "' does not exist.");
148148
}
149149

150150
final DocumentImpl doc = lockedDoc.getDocument();

0 commit comments

Comments
 (0)