forked from 4Science/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DSpace#8991 from mwoodiupui/mediafilter-logging
On media filter failure log the name of the assetstore file and trace causes of exception
- Loading branch information
Showing
2 changed files
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
dspace-api/src/main/java/org/dspace/util/ThrowableUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.util; | ||
|
||
/** | ||
* Things you wish {@link Throwable} or some logging package would do for you. | ||
* | ||
* @author mwood | ||
*/ | ||
public class ThrowableUtils { | ||
/** | ||
* Utility class: do not instantiate. | ||
*/ | ||
private ThrowableUtils() { } | ||
|
||
/** | ||
* Trace a chain of {@code Throwable}s showing only causes. | ||
* Less voluminous than a stack trace. Useful if you just want to know | ||
* what caused third-party code to return an uninformative exception | ||
* message. | ||
* | ||
* @param throwable the exception or whatever. | ||
* @return list of messages from each {@code Throwable} in the chain, | ||
* separated by '\n'. | ||
*/ | ||
static public String formatCauseChain(Throwable throwable) { | ||
StringBuilder trace = new StringBuilder(); | ||
trace.append(throwable.getMessage()); | ||
Throwable cause = throwable.getCause(); | ||
while (null != cause) { | ||
trace.append("\nCaused by: ") | ||
.append(cause.getClass().getCanonicalName()).append(' ') | ||
.append(cause.getMessage()); | ||
cause = cause.getCause(); | ||
} | ||
return trace.toString(); | ||
} | ||
} |