package com.oguerreiro.resilient.expression.error;

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

public abstract class ResilientExpressionFunctionException extends Exception {
  private List<Object> messageArgs;

  protected ResilientExpressionFunctionException(String message) {
    super(message);
  }

  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();
  }
}
