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

de.zalando.sprocwrapper.sharding.ShardedDataAccessException Maven / Gradle / Ivy

Go to download

Library to make PostgreSQL stored procedures available through simple Java "*SProcService" interfaces including automatic object serialization and deserialization (using typemapper and convention-over-configuration). Supports sharding, advisory locking, statement timeouts and PostgreSQL types such as enums and hstore.

There is a newer version: 2.0.0
Show newest version
package de.zalando.sprocwrapper.sharding;

import java.util.Map;

import org.springframework.dao.DataAccessException;

import com.google.common.collect.ImmutableMap;

/**
 * Signals that at an exception has occurred while executing the sproc on the shards.
 *
 * @author  pribeiro
 */
public class ShardedDataAccessException extends DataAccessException {

    private final Map causes;

    /**
     * Creates a {@code ShardedDataAccessException} with specified detail message and causes.
     *
     * @param  msg     the detail message
     * @param  causes  the causes
     */
    public ShardedDataAccessException(final String msg, final Map causes) {
        super(msg);

        // create an immutable map, no one should be able to change the causes.
        // Performance hint. Pass an immutable map into the constructor, so no copy is performed at all
        this.causes = (causes == null ? ImmutableMap.of() : ImmutableMap.copyOf(causes));

        // add causes to new java 7 suppressed exceptions feature so we can see all nested exceptions in stacktrace
        for (final Throwable cause : this.causes.values()) {
            addSuppressed(cause);
        }
    }

    /**
     * Returns an immutable map with the shard id and respective cause.
     *
     * @return  an immutable map with the shard id and respective cause
     */
    public Map getCauses() {
        return causes;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy