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

org.rapaio.jupyter.kernel.message.messages.IOPubError Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package org.rapaio.jupyter.kernel.message.messages;

import java.util.List;
import java.util.function.Function;

import org.rapaio.jupyter.kernel.message.ContentType;
import org.rapaio.jupyter.kernel.message.MessageType;

import com.google.gson.annotations.SerializedName;

/**
 * See also {@link ErrorReply}
 */
public record IOPubError(
        @SerializedName("ename") String errName,
        @SerializedName("evalue") String errMsg,
        @SerializedName("traceback") List stacktrace) implements ContentType {

    public static IOPubError of(Exception exception, Function> formatter) {
        String name = exception.getClass().getSimpleName();
        String msg = exception.getLocalizedMessage();
        List stacktrace = formatter.apply(exception);

        return new IOPubError(name, msg == null ? "" : msg, stacktrace);
    }

    @Override
    public MessageType type() {
        return MessageType.IOPUB_ERROR;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy