public class UtilThrowable extends Object
This is useful in case our application generate very long stack trace (i.e Spark/functional API)
Or, we want to store generated stack trace to a database BACKEND like ELASTICSEARCH !
USAGE:
try {
throw new PMLException("hello world");
} catch (Exception e) {
// this
UtilThrowable.asJsonString(e);
// or
UtilThrowable.asJsonString(e, String[] {"1", "2", "3"});
// or
Map messages = new HashMap<>();
messages.put("hello1", "world1");
UtilThrowable.asJsonString(e, messages);
// and so on...
}
Modifier and Type | Field and Description |
---|---|
static String |
MESSAGE |
static String |
RUNTIME_MESSAGE_ERROR |
Modifier and Type | Method and Description |
---|---|
static String |
asJsonString(Throwable throwAble)
Note: does not respect standard error message format used in API, i.e: http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655
|
static String |
asJsonString(Throwable throwAble,
Object otherMessage)
Note: does not respect standard error message format used in API, i.e: http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655
|
static String |
asJsonStringWithECSErrorCompliance(Throwable throwAble,
ECSError ecsError,
PunchMeta punchMeta,
ISettingsMap labels,
String message,
ISettingsMap userDefinedKeyValues)
NOTE it is possible to set tags through environment variable.
|
public static final String MESSAGE
public static final String RUNTIME_MESSAGE_ERROR
public static String asJsonString(Throwable throwAble)
throwAble
- a class that extends a throwablecom.fasterxml.jackson.core.JsonProcessingException
public static String asJsonString(Throwable throwAble, Object otherMessage)
throwAble
- a class that extends a throwableotherMessage
- can be any object that can be serialized as a String, i.e String[] obj = { "1", "2" }, Mapcom.fasterxml.jackson.core.JsonProcessingException
public static String asJsonStringWithECSErrorCompliance(Throwable throwAble, ECSError ecsError, PunchMeta punchMeta, ISettingsMap labels, String message, ISettingsMap userDefinedKeyValues)
Any environment variables that has for prefix: PUNCHPLATFORM_TAGS will be displayed within the tags key.
throwAble
- (cannot be null) exception that should be thrownecsError
- (cannot be null) an instance of ECSError with initialized variables from constructor onlypunchMeta
- (can be null) meta information of punchlines and punchplatformlabels
- (can be null) Custom key/value pairs. Can be used to add meta information to events. Should not contain nested objects. All values are stored as keyword. example: {'application': 'foo-bar', 'env': 'production'}message
- (can be null) a custom error message you wish to show for this exception eventuserDefinedKeyValues
- (can be null) if you want to define a new group of information. i.e host : { id: ..., uptime: ..., etc... }, tls: { ... }Copyright © 2014–2023. All rights reserved.