Skip to content

Commit

Permalink
Issue 51372: ProteomeXchangeServiceException in org.labkey.panoramapu…
Browse files Browse the repository at this point in the history
…blic.proteomexchange.ProteomeXchangeService.postPxXml() (#501)

- ProteomeXchangeServiceException implements SkipMothershipLogging. Added logging
  • Loading branch information
vagisha authored Feb 5, 2025
1 parent fe000c3 commit 7ada43f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.logging.LogHelper;

import java.io.File;
import java.io.IOException;
Expand All @@ -45,6 +47,8 @@ public class ProteomeXchangeService

private enum METHOD {submitDataset, validateXML, requestID}

private static final Logger LOG = LogHelper.getLogger(ProteomeXchangeService.class, "Handles requests to the ProteomeXchange server");

public static String validatePxXml(File pxxmlFile, boolean testDatabase, String user, String pass) throws ProteomeXchangeServiceException
{
return postPxXml(pxxmlFile, testDatabase, user, pass, METHOD.validateXML);
Expand Down Expand Up @@ -86,7 +90,7 @@ public static String getPxIdResponse(boolean testDatabase, String user, String p
}
catch (Exception e)
{
throw new ProteomeXchangeServiceException("Error requesting a ID from ProteomeXchange.", e);
throw new ProteomeXchangeServiceException("Error requesting a ID from ProteomeXchange. " + e.getMessage(), e);
}

return responseMessage;
Expand Down Expand Up @@ -160,6 +164,7 @@ private static String postRequest(MultipartEntityBuilder builder) throws IOExcep
int statusCode = response.getCode();
if (statusCode != 200)
{
LOG.error("Unsuccessful request to ProteomeXchange. Status code: " + statusCode + "; Response: " + responseMessage);
throw new ProteomeXchangeServiceException("Error " + statusCode + " from ProteomeXchange server: " + responseMessage);
}
return responseMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/
package org.labkey.panoramapublic.proteomexchange;

public class ProteomeXchangeServiceException extends Exception
import org.labkey.api.util.SkipMothershipLogging;

public class ProteomeXchangeServiceException extends Exception implements SkipMothershipLogging
{
public ProteomeXchangeServiceException(String message, Throwable cause)
{
Expand Down

0 comments on commit 7ada43f

Please sign in to comment.