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

org.valkyriercp.image.NoSuchImageResourceException Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package org.valkyriercp.image;

import org.springframework.core.io.Resource;

/**
 * Indicates that a image resource could not be found from an underlying data
 * source.
 *
 * @author Keith Donald
 */
public class NoSuchImageResourceException extends RuntimeException {
    private Object imageKey;

    /**
     * Creates an exception message indicating the specified imageKey did not
     * map to a valid resource.
     *
     * @param imageKey
     *            The unknown image key.
     */
    public NoSuchImageResourceException(Object imageKey) {
        super();
        this.imageKey = imageKey;
    }

    /**
     * Creates an exception message indicating the specified imageKey did not
     * map to a valid resource. A cause is provided.
     *
     * @param imageKey
     *            The unknown image key.
     * @param cause
     *            The reason the resource was not found.
     */
    public NoSuchImageResourceException(Object imageKey, Throwable cause) {
        super(cause);
        this.imageKey = imageKey;
    }

    public String getMessage() {
        if (Resource.class.isInstance(imageKey))
            return "No image at resource '" + imageKey + "' exists.";

        return "No image with key '" + imageKey + "' exists in source bundle.";
    }

    public String toString() {
        return getMessage();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy