- public ErrorTransport(int statusCode, String errMsg, Exception exception) {
- this.status = statusCode;
- this.error = errMsg;
- if (exception != null) {
- final int enough = 512;
- String exString = exception.toString();
- String exceptionMsg = exString.length() > enough ? exString.substring(0, enough) : exString;
- this.exception = exceptionMsg;
- }
+ public ErrorTransport(int status, Throwable throwable) {
+ this.timestamp = Instant.now();
+ this.status = status;
+ final int enough = 256;
+ String exString = throwable.toString();
+ this.error = exString.length() > enough ? exString.substring(0, enough) : exString;
+ }
+
+ /**
+ * Builds an object with all fields
+ *
+ * @param status
+ * Integer value like 500
+ * @param error
+ * Explanation
+ * @param message
+ * Additional explanation
+ * @param path
+ * Requested path
+ */
+ public ErrorTransport(int status, String error, String message, String path) {
+ this.timestamp = Instant.now();
+ this.status = status;
+ this.error = error;
+ this.message = message;
+ this.path = path;