com.devonfw.cobigen.api.exception.MergeException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-api Show documentation
Show all versions of core-api Show documentation
A Code-based incremental Generator
package com.devonfw.cobigen.api.exception;
import java.io.File;
import java.nio.file.Path;
/**
* This Exception indicates a problem while merging.
*/
public class MergeException extends CobiGenRuntimeException {
/** Generated Serial Version UID */
private static final long serialVersionUID = 1;
/** Message constant */
private static final String UNABLE_TO_MERGE = "Unable to merge ";
/** Message constant */
private static final String A_GENERATED_PATCH = "a generated patch";
/**
* Creates an exception for the base file to be merged with the given message.
* @param baseFile
* file to be merged
* @param msg
* error message
*/
public MergeException(File baseFile, String msg) {
super(UNABLE_TO_MERGE + A_GENERATED_PATCH + " into file " + baseFile + ": " + msg);
}
/**
* Creates an exception for the base file to be merged with the given message and root cause.
* @param baseFile
* file to be merged
* @param msg
* error message
* @param cause
* root cause
*/
public MergeException(File baseFile, String msg, Throwable cause) {
super(UNABLE_TO_MERGE + A_GENERATED_PATCH + " into file " + baseFile + ": " + msg, cause);
}
/**
* Copy constructor enriching the error message with further information about the patch.
* @param source
* {@link MergeException} to be used as source for copying
* @param templatePath
* path to the template
*/
public MergeException(MergeException source, Path templatePath) {
super(source.getMessage().replace(A_GENERATED_PATCH, "the patch generated by template " + templatePath),
source.getCause());
}
}