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

me.alidg.errors.ExceptionRefiner Maven / Gradle / Ivy

package me.alidg.errors;

import org.springframework.lang.Nullable;

/**
 * Defines a contract to refine exceptions. Sometimes we need to dig deeper to find the
 * actual cause of the problem. This interface can help us to transform the given exception
 * before handling it.
 *
 * @author Ali Dehghani
 * @implNote Do not throw exceptions in method implementations.
 */
public interface ExceptionRefiner {

    /**
     * Performs the actual mechanics of exception transformation.
     *
     * 

Please note that both the method parameter and return type are nullable.

* * @param exception The exception to refine. * @return The refined exception. */ @Nullable Throwable refine(@Nullable Throwable exception); /** * A NoOp implementation for the {@link ExceptionRefiner}. * * @author zarebski-m */ enum NoOp implements ExceptionRefiner { /** * The singleton instance. */ INSTANCE; /** * Does nothing special. * * @param exception The exception to refine. * @return null, always. */ @Override public Throwable refine(Throwable exception) { return null; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy