-
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.
- Loading branch information
Showing
6 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/com/TurquoiseSpace/constant/ErrorConstants.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,9 @@ | ||
package com.TurquoiseSpace.constant; | ||
|
||
public interface ErrorConstants { | ||
|
||
public static final String ERROR_ENCOUNTERED = "Encountered Error -> (class) {} (message) {}"; | ||
|
||
public static final String ERROR_PARSED = "Parsed Error -> (json) {}"; | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/TurquoiseSpace/constant/ExceptionConstants.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,9 @@ | ||
package com.TurquoiseSpace.constant; | ||
|
||
public interface ExceptionConstants { | ||
|
||
public static final String EXCEPTION_ENCOUNTERED = "Encountered Exception -> (class) {} (message) {}"; | ||
|
||
public static final String EXCEPTION_PARSED = "Parsed Exception -> (json) {}"; | ||
|
||
} |
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
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
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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/TurquoiseSpace/utility/ThrowableLogUtil.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,38 @@ | ||
package com.TurquoiseSpace.utility; | ||
|
||
import com.TurquoiseSpace.constant.ThrowableConstants; | ||
import com.TurquoiseSpace.model.GenericException; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class ThrowableLogUtil { | ||
|
||
private static GenericException makeGenericException(Throwable throwable, String customMessage) { | ||
if (null == customMessage || customMessage.trim().isEmpty()) { | ||
return new GenericException(throwable); | ||
} else { | ||
return new GenericException(throwable, customMessage); | ||
} | ||
} | ||
|
||
public static String getThrowableJson(Throwable throwable, String customMessage) { | ||
log.debug(ThrowableConstants.THROWABLE_ENCOUNTERED, throwable.getClass().getName(), throwable.getMessage(), throwable); | ||
GenericException genericException = makeGenericException(throwable, customMessage); | ||
return JsonUtil.convertObjectToJson(genericException); | ||
} | ||
|
||
public static String getThrowableJson(Throwable throwable) { | ||
return getThrowableJson(throwable, null); | ||
} | ||
|
||
public static void logThrowable(Throwable throwable, String customMessage) { | ||
String throwableJson = getThrowableJson(throwable, customMessage); | ||
log.error(ThrowableConstants.THROWABLE_PARSED, throwableJson); | ||
} | ||
|
||
public static void logThrowable(Throwable throwable) { | ||
logThrowable(throwable, null); | ||
} | ||
|
||
} |