package com.github.blindpirate.gogradle.core.exceptions;

import com.github.blindpirate.gogradle.core.dependency.GolangDependency;
import com.github.blindpirate.gogradle.core.dependency.ResolvedDependency;
import com.github.blindpirate.gogradle.core.dependency.VendorNotationDependency;
import com.github.blindpirate.gogradle.vcs.GitMercurialNotationDependency;
import org.gradle.api.GradleException;

import java.io.File;

public final class DependencyResolutionException extends GradleException {
    private DependencyResolutionException(String message) {
        super(message);
    }

    private DependencyResolutionException(String message, Throwable cause) {
        super(message, cause);
    }

    public static DependencyResolutionException cannotCloneRepository(GolangDependency dependency, Throwable e) {
        return new DependencyResolutionException("Cloning repository of " + dependency.getName() + " failed.", e);
    }

    public static DependencyResolutionException cannotParseNotation(Object notation) {
        return new DependencyResolutionException("Cannot parse notation " + String.valueOf(notation));
    }

    public static DependencyResolutionException cannotFindGitCommit(
            GitMercurialNotationDependency gitMercurialNotationDependency) {
        return new DependencyResolutionException("Cannot find commit " + gitMercurialNotationDependency.getCommit()
                + " in repository of "
                + gitMercurialNotationDependency.getName()
                + ", did they force to delete this commit?");
    }

    public static DependencyResolutionException cannotResolveDependency(
            GolangDependency dependency, Exception e) {
        return new DependencyResolutionException("Cannot resolve dependency:" + dependency, e);
    }

    public static DependencyResolutionException directoryIsInvalid(File rootDir) {
        return new DependencyResolutionException("Directory is invalid:" + rootDir.getPath());
    }


    public static DependencyResolutionException vendorNotExist(VendorNotationDependency vendorNotationDependency,
                                                               ResolvedDependency resolvedDependency) {
        return new DependencyResolutionException("vendor dependency " + vendorNotationDependency.toString()
                + " does not exist in transitive dependencies in " + resolvedDependency);
    }
}

@@ -116,32 +116,107 @@
 langDependency;%0A
+import com.github.blindpirate.gogradle.core.dependency.NotationDependency;%0A
 import com.githu
@@ -266,32 +266,32 @@
 lvedDependency;%0A
-
 import com.githu
@@ -847,35 +847,19 @@
 ory(
-GolangDependency dependency
+String name
 , Th
@@ -951,28 +951,12 @@
 %22 + 
-dependency.getN
+n
 ame
-()
  + %22
@@ -1568,17 +1568,8 @@
 hey 
-force to 
 dele
@@ -2338,16 +2338,16 @@
 tring()%0A
-
         
@@ -2433,11 +2433,373 @@
 );%0A    %7D
+%0A%0A    public static DependencyResolutionException cannotFindGitTag(NotationDependency dependency, String tag) %7B%0A        return new DependencyResolutionException(%22Cannot find tag %22 + tag%0A                + %22 in repository of %22%0A                + GitMercurialNotationDependency.class.cast(dependency).getName()%0A                + %22, did they delete this tag?%22);%0A    %7D
 %0A%7D%0A

Add an exception util methods