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

com.varmateo.yawg.core.DirBakerException Maven / Gradle / Ivy

/**************************************************************************
 *
 * Copyright (c) 2019 Yawg project contributors.
 *
 **************************************************************************/

package com.varmateo.yawg.core;

import java.io.IOException;
import java.nio.file.Path;
import java.util.function.Function;

import com.varmateo.yawg.api.YawgException;


/**
 *
 */
/* default */ final class DirBakerException
        extends YawgException {


    private DirBakerException(
            final String msg,
            final Throwable cause) {

        super(msg, cause);
    }


    /**
     *
     */
    public static DirBakerException directoryCreationFailure(
            final Path dirPath,
            final IOException cause) {

        final String msg = String.format(
                "Failed to create directory \"%s\" - %s - %s",
                dirPath,
                cause.getClass().getName(),
                cause.getMessage());

        return new DirBakerException(msg, cause);
    }


    /**
     *
     */
    public static Function directoryCreationFailure(
            final Path dirPath) {

        return cause -> directoryCreationFailure(dirPath, cause);
    }


    /**
     *
     */
    public static DirBakerException directoryListFailure(
            final Path dirPath,
            final IOException cause) {

        final String msg = String.format(
                "Failed to list directory \"%s\" - %s - %s",
                dirPath,
                cause.getClass().getName(),
                cause.getMessage());

        return new DirBakerException(msg, cause);
    }


    /**
     *
     */
    public static Function directoryListFailure(
            final Path dirPath) {

        return cause -> directoryListFailure(dirPath, cause);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy