// Path: src/main/java/killrvideo/utils/ExceptionUtils.java
// public class ExceptionUtils {
// 
//     public static final String mergeStackTrace(Throwable throwable) {
//         StringJoiner joiner = new StringJoiner("\n\t", "\n", "\n");
//         joiner.add(throwable.getMessage());
//         Arrays.asList(throwable.getStackTrace())
//              .forEach(stackTraceElement -> joiner.add(stackTraceElement.toString()));
// 
//         return joiner.toString();
//     }
// }


import com.google.protobuf.GeneratedMessageV3;
import killrvideo.utils.ExceptionUtils;
package killrvideo.events;



/**
 * Error bean to be published in BUS.
 *
 * @author DataStax evangelist team.
 */
public class CassandraMutationError {

    /**
     * Failed Protobuf requests.
     */
    public final GeneratedMessageV3 request;
    
    /**
     * Related exception in code.
     */
    public final Throwable throwable;

    /**
     * Default constructor.
     */
    public CassandraMutationError(GeneratedMessageV3 request, Throwable throwable) {
        this.request = request;
        this.throwable = throwable;
    }

    /**
     * Display as an error message.
     */
    public String buildErrorLog() {
        StringBuilder builder = new StringBuilder();
        builder.append(request.toString()).append("\n");
        builder.append(throwable.getMessage()).append("\n");
// Path: src/main/java/killrvideo/utils/ExceptionUtils.java
// public class ExceptionUtils {
// 
//     public static final String mergeStackTrace(Throwable throwable) {
//         StringJoiner joiner = new StringJoiner("\n\t", "\n", "\n");
//         joiner.add(throwable.getMessage());
//         Arrays.asList(throwable.getStackTrace())
//              .forEach(stackTraceElement -> joiner.add(stackTraceElement.toString()));
// 
//         return joiner.toString();
//     }
// }


// Path: src/main/java/killrvideo/events/CassandraMutationError.java
import com.google.protobuf.GeneratedMessageV3;
import killrvideo.utils.ExceptionUtils;

package killrvideo.events;



/**
 * Error bean to be published in BUS.
 *
 * @author DataStax evangelist team.
 */
public class CassandraMutationError {

    /**
     * Failed Protobuf requests.
     */
    public final GeneratedMessageV3 request;
    
    /**
     * Related exception in code.
     */
    public final Throwable throwable;

    /**
     * Default constructor.
     */
    public CassandraMutationError(GeneratedMessageV3 request, Throwable throwable) {
        this.request = request;
        this.throwable = throwable;
    }

    /**
     * Display as an error message.
     */
    public String buildErrorLog() {
        StringBuilder builder = new StringBuilder();
        builder.append(request.toString()).append("\n");
        builder.append(throwable.getMessage()).append("\n");
        builder.append(ExceptionUtils.mergeStackTrace(throwable));