// Path: services-core/src/main/java/io/plumery/core/Event.java
// public abstract class Event implements Action {
//     public int version;
//     public ID id;
// }
// 
// Path: services-core/src/main/java/io/plumery/core/ID.java
// public class ID implements Serializable {
//     private final String id;
// 
//     private ID(String id) {
//         this.id = id;
//     }
// 
//     public static ID fromObject(Object id) {
//         if (id instanceof String) {
//             return new ID((String) id);
//         } else if (id instanceof UUID) {
//             return new ID(id.toString());
//         } else {
//             new IllegalArgumentException("The id should be of either String or UUID type");
//         }
// 
//         return null;
//     }
// 
//     public String toString() {
//         return id;
//     }
// }
// 
// Path: services-core/src/main/java/io/plumery/core/exception/ApplicationException.java
// public abstract class ApplicationException extends RuntimeException {
//     private final int version;
//     private ID aggregateRootId;
//     private String action;
// 
//     public ApplicationException(String message,
//                                 ID aggregateRootId,
//                                 int version) {
//         super(message);
//         this.aggregateRootId = aggregateRootId;
//         this.version = version;
//     }
// 
//     public ID getAggregateRootId() {
//         return aggregateRootId;
//     }
// 
//     public int getVersion() {
//         return version;
//     }
// 
//     public String getAction() {
//         return action;
//     }
// 
//     public void setAction(String action) {
//         this.action = action;
//     }
// }
// 
// Path: services-core/src/main/java/io/plumery/core/exception/SystemException.java
// public class SystemException extends RuntimeException {
//     private final String errorEventId;
// 
//     public SystemException(String errorEventId, Exception ex) {
//         super(ex);
//         this.errorEventId = errorEventId;
//     }
// 
//     public String getErrorEventId() {
//         return errorEventId;
//     }
// }


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.plumery.core.Event;
import io.plumery.core.ID;
import io.plumery.core.exception.ApplicationException;
import io.plumery.core.exception.SystemException;
package io.plumery.messaging.utils;


public class EventUtils {
    public static Event exceptionToEvent(Exception ex) {
        String message = ex.getMessage();

        if (ex instanceof ApplicationException) {
// Path: services-core/src/main/java/io/plumery/core/Event.java
// public abstract class Event implements Action {
//     public int version;
//     public ID id;
// }
// 
// Path: services-core/src/main/java/io/plumery/core/ID.java
// public class ID implements Serializable {
//     private final String id;
// 
//     private ID(String id) {
//         this.id = id;
//     }
// 
//     public static ID fromObject(Object id) {
//         if (id instanceof String) {
//             return new ID((String) id);
//         } else if (id instanceof UUID) {
//             return new ID(id.toString());
//         } else {
//             new IllegalArgumentException("The id should be of either String or UUID type");
//         }
// 
//         return null;
//     }
// 
//     public String toString() {
//         return id;
//     }
// }
// 
// Path: services-core/src/main/java/io/plumery/core/exception/ApplicationException.java
// public abstract class ApplicationException extends RuntimeException {
//     private final int version;
//     private ID aggregateRootId;
//     private String action;
// 
//     public ApplicationException(String message,
//                                 ID aggregateRootId,
//                                 int version) {
//         super(message);
//         this.aggregateRootId = aggregateRootId;
//         this.version = version;
//     }
// 
//     public ID getAggregateRootId() {
//         return aggregateRootId;
//     }
// 
//     public int getVersion() {
//         return version;
//     }
// 
//     public String getAction() {
//         return action;
//     }
// 
//     public void setAction(String action) {
//         this.action = action;
//     }
// }
// 
// Path: services-core/src/main/java/io/plumery/core/exception/SystemException.java
// public class SystemException extends RuntimeException {
//     private final String errorEventId;
// 
//     public SystemException(String errorEventId, Exception ex) {
//         super(ex);
//         this.errorEventId = errorEventId;
//     }
// 
//     public String getErrorEventId() {
//         return errorEventId;
//     }
// }


// Path: services-infrastructure-messaging/src/main/java/io/plumery/messaging/utils/EventUtils.java
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.plumery.core.Event;
import io.plumery.core.ID;
import io.plumery.core.exception.ApplicationException;
import io.plumery.core.exception.SystemException;

package io.plumery.messaging.utils;


public class EventUtils {
    public static Event exceptionToEvent(Exception ex) {
        String message = ex.getMessage();

        if (ex instanceof ApplicationException) {
            ApplicationException e = (ApplicationException) ex;