import Failure from "core/failure";
import {
  BaseFailureHandler,
  ResponseFailureHandler,
} from "core/handlers/responseFailureHandler";

class ExecOnAnyHandler
  extends BaseFailureHandler
  implements ResponseFailureHandler
{
  private callback: (reason: Failure) => void;

  constructor(
    callback: (reason: Failure) => void,
    nextHandler?: ResponseFailureHandler
  ) {
    super(nextHandler);
    this.callback = callback;
  }

  handle(reason: Failure): void {
    return this.callback(reason);
  }
}

export default ExecOnAnyHandler;
