Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMetalrom <romain.magny@gmail.com>2013-01-08 17:22:33 +0400
committerMetalrom <romain.magny@gmail.com>2013-01-10 17:20:03 +0400
commitf493cec11c03fdc185b73965c5d586350b9ebf38 (patch)
tree345bdbe6fc5546560cc78645cea759f3e8c6a966
parent191bd74c933427a377a5eb2ffeb4a0f39a26ceb0 (diff)
Add InvalidSpecificationException as wrapper for EINVALIDSPEC native exception
-rw-r--r--LibGit2Sharp.Tests/TagFixture.cs8
-rw-r--r--LibGit2Sharp/Core/Ensure.cs3
-rw-r--r--LibGit2Sharp/Core/GitErrorCode.cs2
-rw-r--r--LibGit2Sharp/InvalidSpecificationException.cs54
-rw-r--r--LibGit2Sharp/LibGit2Sharp.csproj1
5 files changed, 63 insertions, 5 deletions
diff --git a/LibGit2Sharp.Tests/TagFixture.cs b/LibGit2Sharp.Tests/TagFixture.cs
index 8d1c146c..30272a43 100644
--- a/LibGit2Sharp.Tests/TagFixture.cs
+++ b/LibGit2Sharp.Tests/TagFixture.cs
@@ -307,10 +307,10 @@ namespace LibGit2Sharp.Tests
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<ArgumentException>(() => repo.ApplyTag(""));
- Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag(".othertag"));
- Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("other tag"));
- Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("othertag^"));
- Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("other~tag"));
+ Assert.Throws<InvalidSpecificationException>(() => repo.ApplyTag(".othertag"));
+ Assert.Throws<InvalidSpecificationException>(() => repo.ApplyTag("other tag"));
+ Assert.Throws<InvalidSpecificationException>(() => repo.ApplyTag("othertag^"));
+ Assert.Throws<InvalidSpecificationException>(() => repo.ApplyTag("other~tag"));
}
}
diff --git a/LibGit2Sharp/Core/Ensure.cs b/LibGit2Sharp/Core/Ensure.cs
index 7998bebd..3a839fff 100644
--- a/LibGit2Sharp/Core/Ensure.cs
+++ b/LibGit2Sharp/Core/Ensure.cs
@@ -84,6 +84,9 @@ namespace LibGit2Sharp.Core
case (int)GitErrorCode.Exists:
throw new NameConflictException(errorMessage, (GitErrorCode)result, error.Category);
+ case (int)GitErrorCode.InvalidSpecification:
+ throw new InvalidSpecificationException(errorMessage, (GitErrorCode)result, error.Category);
+
default:
throw new LibGit2SharpException(errorMessage, (GitErrorCode)result, error.Category);
}
diff --git a/LibGit2Sharp/Core/GitErrorCode.cs b/LibGit2Sharp/Core/GitErrorCode.cs
index 7322ef26..776229e3 100644
--- a/LibGit2Sharp/Core/GitErrorCode.cs
+++ b/LibGit2Sharp/Core/GitErrorCode.cs
@@ -53,7 +53,7 @@
/// <summary>
/// Input is not a valid specification.
/// </summary>
- InvalidSpecification = -11,
+ InvalidSpecification = -12,
/// <summary>
/// Skip and passthrough the given ODB backend.
diff --git a/LibGit2Sharp/InvalidSpecificationException.cs b/LibGit2Sharp/InvalidSpecificationException.cs
new file mode 100644
index 00000000..3d497b73
--- /dev/null
+++ b/LibGit2Sharp/InvalidSpecificationException.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Runtime.Serialization;
+using LibGit2Sharp.Core;
+
+namespace LibGit2Sharp
+{
+ /// <summary>
+ /// The exception that is thrown when the provided specification is syntactically incorrect.
+ /// </summary>
+ [Serializable]
+ public class InvalidSpecificationException : LibGit2SharpException
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref = "InvalidSpecificationException" /> class.
+ /// </summary>
+ public InvalidSpecificationException()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref = "InvalidSpecificationException" /> class with a specified error message.
+ /// </summary>
+ /// <param name = "message">A message that describes the error. </param>
+ public InvalidSpecificationException(string message)
+ : base(message)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref = "InvalidSpecificationException" /> class with a specified error message and a reference to the inner exception that is the cause of this exception.
+ /// </summary>
+ /// <param name = "message">The error message that explains the reason for the exception. </param>
+ /// <param name = "innerException">The exception that is the cause of the current exception. If the <paramref name = "innerException" /> parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
+ public InvalidSpecificationException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref = "InvalidSpecificationException" /> class with a serialized data.
+ /// </summary>
+ /// <param name = "info">The <see cref="SerializationInfo "/> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name = "context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
+ protected InvalidSpecificationException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
+
+ internal InvalidSpecificationException(string message, GitErrorCode code, GitErrorCategory category)
+ : base(message, code, category)
+ {
+ }
+ }
+}
diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj
index f44174c9..7664ce89 100644
--- a/LibGit2Sharp/LibGit2Sharp.csproj
+++ b/LibGit2Sharp/LibGit2Sharp.csproj
@@ -71,6 +71,7 @@
<Compile Include="ConfigurationEntry.cs" />
<Compile Include="ConfigurationExtensions.cs" />
<Compile Include="ContentChanges.cs" />
+ <Compile Include="InvalidSpecificationException.cs" />
<Compile Include="Core\Compat\EnumExtensions.cs" />
<Compile Include="Core\GitCheckoutOpts.cs" />
<Compile Include="Core\GitCloneOptions.cs" />