package com.eactive.eai.transformer.message;

public class InvalidAccessException extends MessageException {
	private static final long serialVersionUID = -4083014709237636334L;
	private final String itemPath;
    private Message m;

    public InvalidAccessException(String message, String itemPath) {
        this(message, itemPath, null, null);
    }

    public InvalidAccessException(String itemPath, Throwable cause) {
        super(cause.getMessage(), cause);
        this.itemPath = itemPath;
    }
    
    public InvalidAccessException(String message, String itemPath, Message m, Throwable cause) {
        super(message, cause);
        this.itemPath = itemPath;
        this.m = m;
    }
    
    @Override
    public String getMessage() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.getMessage() + "\n");
        sb.append("전문레이아웃=");
        sb.append(((itemPath == null) ? "null" : itemPath)+"\n");
        sb.append(super.getCause() + "\n");
        
        sb.append(dumpMessage(m));
        
        return sb.toString();                                                                                            
    }
}
