Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
package com.marklogic.client;

import com.marklogic.client.impl.FailedRequest;
import com.marklogic.client.impl.RESTServices;

/**
* Abstract class that implements functionality for errors returned from a MarkLogic REST API instance.
Expand Down Expand Up @@ -51,7 +52,7 @@ else if (failedRequest != null) {
* @return the status code
*/
public int getServerStatusCode() {
return (failedRequest == null) ? null : failedRequest.getStatusCode();
return (failedRequest == null) ? RESTServices.STATUS_UNKNOWN : failedRequest.getStatusCode();
}
/**
* Gets the HTTP status message (if any) associated with the error on the server.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
package com.marklogic.client.impl;

Expand Down Expand Up @@ -68,6 +68,7 @@ public interface RESTServices {
String MIMETYPE_APPLICATION_XML = "application/xml";
String MIMETYPE_MULTIPART_MIXED = "multipart/mixed";

int STATUS_UNKNOWN = -1;
int STATUS_OK = 200;
int STATUS_CREATED = 201;
int STATUS_NO_CONTENT = 204;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
package com.marklogic.client.test;

import com.marklogic.client.*;
import com.marklogic.client.admin.QueryOptionsManager;
import com.marklogic.client.document.XMLDocumentManager;
import com.marklogic.client.impl.FailedRequest;
import com.marklogic.client.io.Format;
import com.marklogic.client.io.StringHandle;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -100,4 +101,15 @@ public void testFailedRequestParsing() {
fail("Call failed with unexpected exception: "+e.getMessage());
}
}

@Test
public void testNullFailedRequestInFailedRequestException() {
FailedRequestException e = new FailedRequestException("test", (FailedRequest) null);
assertEquals("test", e.getMessage());
assertEquals(-1, e.getServerStatusCode());
assertNull(e.getServerStatus());
assertNull(e.getServerMessageCode());
assertNull(e.getServerMessage());
assertNull(e.getServerStackTrace());
}
}
Loading