package com.oguerreiro.resilient.error;

public class UnitConverterExpressionEvaluationRuntimeException extends ResilientRuntimeException {
  private static final String CODE = "E013";

  public UnitConverterExpressionEvaluationRuntimeException(String variableCode, String fromUnitCode, String toUnitCode,
      String sourceValue, ExpressionEvaluationException cause) {
    super("An error occurred calculating the unit converter: Variable Code [" + variableCode + "], From Unit Code ["
        + fromUnitCode + "], To Unit Code [" + toUnitCode + "], Value [" + sourceValue + "]. With the following error: "
        + cause.getMessage());

    addMessageArg(variableCode);
    addMessageArg(fromUnitCode);
    addMessageArg(toUnitCode);
    addMessageArg(sourceValue);
    addMessageArg(cause.getMessage());
  }

  @Override
  public String getMessageCode() {
    return CODE;
  }

}
