/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira.drafts
 */

package net.ranides.assira.trace;

import java.lang.management.ManagementFactory;
import java.text.MessageFormat;
import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class EQException extends NSTException {
    
    private static final AtomicInteger COUNTER = new AtomicInteger(0);
    
    private static final class Li { // NOPMD - lazy init idiom
        
        public static final String VMNAME = ManagementFactory.getRuntimeMXBean().getName();
        
    }
    
    private final String uid;
    private final String text;
    
    public EQException(String message) {
        text = message;
        uid = Li.VMNAME + "@" + COUNTER.incrementAndGet();
    }

    public EQException(String pattern, Object... params) {
        this(MessageFormat.format(pattern, params));
    }

    @Override
    public String toString() {
        return "EMException{ " + uid + " : " + text + " }";
    }

    public String getUid() {
        return uid;
    }

}
