package org.libgit2.jagged.core;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * The error type, as defined by the libgit2 return code.
 */
enum GitErrorType
{
    /**
     * libgit2 has run out of memory.
     */
    GITERR_NOMEMORY(0),

    /**
     * An error occurred with an operating system call.
     */
    GITERR_OS(1),

    /**
     * An unknown error (an error occurred marshalling the error data itself).
     */
    GITERR_UNKNOWN(Integer.MAX_VALUE);

    private final int value;

    private static final Map<Integer, GitErrorType> errorTypes = new HashMap<Integer, GitErrorType>();

    static
    {
        for (GitErrorType errorClass : EnumSet.allOf(GitErrorType.class))
        {
            errorTypes.put(errorClass.getValue(), errorClass);
        }
    }

    private GitErrorType(int value)
    {
        this.value = value;
    }

    private int getValue()
    {
        return value;
    }

    static GitErrorType getErrorType(int value)
    {
        GitErrorType errorType = errorTypes.get(value);
        return errorType != null ? errorType : GITERR_UNKNOWN;
    }
};

@@ -188,16 +188,70 @@
 rType%0A%7B%0A
+    /**%0A     * No error.%0A     */%0A    GITERR_NONE(0),%0A%0A
     /**%0A
@@ -316,17 +316,17 @@
 OMEMORY(
-0
+1
 ),%0A%0A    
@@ -407,17 +407,534 @@
 TERR_OS(
-1
+2),%0A%0A    GITERR_INVALID(3),%0A    GITERR_REFERENCE(4),%0A    GITERR_ZLIB(5),%0A    GITERR_REPOSITORY(6),%0A    GITERR_CONFIG(7),%0A    GITERR_REGEX(8),%0A    GITERR_ODB(9),%0A    GITERR_INDEX(10),%0A    GITERR_OBJECT(11),%0A    GITERR_NET(12),%0A    GITERR_TAG(13),%0A    GITERR_TREE(14),%0A    GITERR_INDEXER(15),%0A    GITERR_SSL(16),%0A    GITERR_SUBMODULE(17),%0A    GITERR_THREAD(18),%0A    GITERR_STASH(19),%0A    GITERR_CHECKOUT(20),%0A    GITERR_FETCHHEAD(21),%0A    GITERR_MERGE(22),%0A    GITERR_SSH(23),%0A    GITERR_FILTER(24),%0A    GITERR_REVERT(25
 ),%0A%0A    

Update error types