All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.algorithmia.development.SerializableException Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.algorithmia.development;

import com.google.gson.JsonObject;

import java.io.PrintWriter;
import java.io.StringWriter;

class SerializableException {
    String message;
    String stackTrace;
    String errorType;

    SerializableException(T e) {

        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        message = e.getMessage();
        stackTrace = exceptionAsString;
        errorType = e.getClass().toString();
    }

    String getJsonOutput() {
        JsonObject node = new JsonObject();
        node.addProperty("message", this.message);
        node.addProperty("stack_trace", this.stackTrace);
        node.addProperty("error_type", this.errorType);
        return node.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy