package com.oguerreiro.resilient.error;

import java.util.ArrayList;
import java.util.List;

public abstract class ResilientRuntimeException extends RuntimeException {
  private static final long serialVersionUID = 1L;
  private List<Object> messageArgs;

  public ResilientRuntimeException(String message) {
    super(message);
  }

  public ResilientRuntimeException(String message, Throwable cause) {
    super(message, cause);
  }

  public abstract String getMessageCode();

  protected void addMessageArg(Object arg) {
    if (this.messageArgs == null)
      this.messageArgs = new ArrayList<Object>();

    this.messageArgs.add(arg);
  }

  protected List<Object> args() {
    return this.messageArgs;
  }

  public Object[] getMessageArgs() {
    return this.messageArgs.toArray();
  }
}
