Skip to content

Commit

Permalink
Refactor the error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
taojing2002 committed Feb 15, 2022
1 parent 11aca03 commit 5db371f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Expand Up @@ -82,7 +82,7 @@ public String mintIdentifier(String siteCode) throws OSTIElinkException {
identifier = service.mintIdentifier(siteCode);
} catch (OSTIElinkException e) {
if (errorAgent != null) {
errorAgent.notify(e);
errorAgent.notify(e.getMessage());
}
throw e;
}
Expand Down
Expand Up @@ -27,8 +27,8 @@ public interface OSTIElinkErrorAgent {

/**
* Send the caught exceptions to the users
* @param e the exception happened during the
* @param error the error message happened during the
* interaction between OSTIElinkClinet and Elink in another thread.
*/
public void notify(Exception e);
public void notify(String error);
}
2 changes: 2 additions & 0 deletions src/main/java/edu/ucsb/nceas/osti_elink/OSTIElinkService.java
Expand Up @@ -64,6 +64,8 @@
*/
public class OSTIElinkService {
public static final String DOI = "doi";
public static final String SAVED = "Saved";
public static final String PENDING = "Pending";

private static final int GET = 1;
private static final int PUT = 2;
Expand Down
Expand Up @@ -94,9 +94,12 @@ public void run() {
break;
}
} catch (Exception e) {
log.error("OSTIElinkServiceRequest - Failed request " + method + " for " + identifier + " since: " + e.getMessage());
String error = "OSTIElinkServiceRequest.run - the request to OSTI for " + identifier + " failed:\n" + metadata +
"\n *************************************************************\n The response from OSIT is:\n " +
e.getMessage();
log.error(error);
if (errorAgent != null) {
errorAgent.notify(e);
errorAgent.notify(error);
}
}
}
Expand Down
Expand Up @@ -28,8 +28,8 @@ public class StringElinkErrorAgent implements OSTIElinkErrorAgent {
String error = "";

@Override
public void notify(Exception e) {
error = error + " " + e.getMessage();
public void notify(String errorMessage) {
error = error + " " + errorMessage;
}

/**
Expand Down

0 comments on commit 5db371f

Please sign in to comment.