package ru.micord.ervu_eks.handler;

import org.springframework.stereotype.Component;
import ru.micord.ervu_eks.exception.ConfigExecutorException;

import ru.cg.webbpm.modules.core.error_handling.api.ProcessedWebException;
import ru.cg.webbpm.modules.core.error_handling.api.WebExceptionHandler;

@Component
public class ConfigExecutorExceptionHandler implements WebExceptionHandler {

  @Override
  public boolean accept(Throwable throwable) {
    return throwable instanceof ConfigExecutorException;
  }

  @Override
  public double weight() {
    return 1000;
  }

  @Override
  public ProcessedWebException process(Throwable throwable) {
    return new ProcessedWebException()
        .addMessage(throwable.getMessage());
  }
}
