8000 Introduce PeelException · kanglingv/libgit2sharp@1a3249c · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a3249c

Browse files
committed
Introduce PeelException
8000
1 parent fc2a47c commit 1a3249c

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ public void LookingUpByAWrongRevParseExpressionThrows()
504504
Assert.Throws<InvalidSpecificationException>(() => repo.Lookup<Commit>("tags/point_to_blob^{commit}"));
505505
Assert.Throws<InvalidSpecificationException>(() => repo.Lookup("master^{tree}^{blob}"));
506506
Assert.Throws<InvalidSpecificationException>(() => repo.Lookup<Blob>("master^{blob}"));
507+
Assert.Throws<PeelException>(() => repo.Lookup<Blob>("tags/e90810b^{blob}"));
507508
}
508509
}
509510

LibGit2Sharp/Core/Ensure.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ private static readonly Dictionary<GitErrorCode, Func<string, GitErrorCode, GitE
101101
{ GitErrorCode.MergeConflict, (m, r, c) => new MergeConflictException(m, r, c) },
102102
{ GitErrorCode.LockedFile, (m, r, c) => new LockedFileException(m, r, c) },
103103
{ GitErrorCode.NotFound, (m, r, c) => new NotFoundException(m, r, c) },
104+
{ GitErrorCode.Peel, (m, r, c) => new PeelException(m, r, c) },
104105
};
105106

106107
private static void HandleError(int result)

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<Compile Include="GitObjectMetadata.cs" />
9999
<Compile Include="PatchEntryChanges.cs" />
100100
<Compile Include="PatchStats.cs" />
101+
<Compile Include="PeelException.cs" />
101102
<Compile Include="PullOptions.cs" />
102103
<Compile Include="RefSpec.cs" />
103104
<Compile Include="RefSpecCollection.cs" />

LibGit2Sharp/PeelException.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
using LibGit2Sharp.Core;
4+
5+
namespace LibGit2Sharp
6+
{
7+
/// <summary>
8+
/// The exception that is thrown when a tag cannot be peeled to the
9+
/// target type due to the object model.
10+
/// </summary>
11+
[Serializable]
12+
public class PeelException : LibGit2SharpException
13+
{
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="PeelException"/> class.
16+
/// </summary>
17+
public PeelException()
18+
{
19+
}
20+
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="PeelException"/> class with a specified error message.
23+
/// </summary>
24+
/// <param name="message">A message that describes the error.</param>
25+
public PeelException(string message)
26+
: base(message)
27+
{
28+
}
29+
30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="PeelException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
32+
/// </summary>
33+
/// <param name="message">The error message that explains the reason for the exception.</param>
34+
/// <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>
35+
public PeelException(string message, Exception innerException)
36+
: base(message, innerException)
37+
{
38+
}
39+
40+
/// <summary>
41+
/// Initializes a new instance of the <see cref="PeelException"/> class with a serialized data.
42+
/// </summary>
43+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
44+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
45+
protected PeelException(SerializationInfo info, StreamingContext context)
46+
: base(info, context)
47+
{
48+
}
49+
50+
internal PeelException(string message, GitErrorCode code, GitErrorCategory category)
51+
: base(message, code, category)
52+
{
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)
0