All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fridujo.automocker.api.jms.ErrorHandlerMock Maven / Gradle / Ivy

The newest version!
package com.github.fridujo.automocker.api.jms;

import com.github.fridujo.automocker.api.Resettable;
import org.springframework.util.ErrorHandler;

import java.util.Optional;

public class ErrorHandlerMock implements ErrorHandler, Resettable {

    private final Optional delegate;
    private Throwable lastCatched = null;

    ErrorHandlerMock(Optional delegate) {
        this.delegate = delegate;
    }

    @Override
    public void handleError(Throwable t) {
        lastCatched = t;
        delegate.ifPresent(e -> e.handleError(t));
    }

    public Optional getLastCatched() {
        return Optional.ofNullable(lastCatched);
    }

    @Override
    public void reset() {
        this.lastCatched = null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy