-
Notifications
You must be signed in to change notification settings - Fork 923
Throw NotFound and CannotDereference Exceptions - Reborn #842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ | |
| namespace LibGit2Sharp | ||
| { | ||
| /// <summary> | ||
| /// The exception that is thrown when the provided specification is syntactically incorrect. | ||
| /// The exception that is thrown when a provided specification is bad. This | ||
| /// can happen if the provided specification is syntactically incorrect, or | ||
| /// if the spec refers to an object of an incorrect type (e.g. asking to | ||
| /// create a branch from a blob, or peeling a blob to a commit). | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| /// </summary> | ||
| [Serializable] | ||
| public class InvalidSpecificationException : LibGit2SharpException | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using System; | ||
| using System.Runtime.Serialization; | ||
| using LibGit2Sharp.Core; | ||
|
|
||
| namespace LibGit2Sharp | ||
| { | ||
| /// <summary> | ||
| /// The exception that is thrown when a tag cannot be peeled to the | ||
| /// target type due to the object model. | ||
| /// </summary> | ||
| [Serializable] | ||
| public class PeelException : LibGit2SharpException | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="PeelException"/> class. | ||
| /// </summary> | ||
| public PeelException() | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="PeelException"/> class with a specified error message. | ||
| /// </summary> | ||
| /// <param name="message">A message that describes the error.</param> | ||
| public PeelException(string message) | ||
| : base(message) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// 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. | ||
| /// </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 PeelException(string message, Exception innerException) | ||
| : base(message, innerException) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="PeelException"/> 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 PeelException(SerializationInfo info, StreamingContext context) | ||
| : base(info, context) | ||
| { | ||
| } | ||
|
|
||
| internal PeelException(string message, GitErrorCode code, GitErrorCategory category) | ||
| : base(message, code, category) | ||
| { | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still feel a little bothered that those two above throw different exceptions.
FWIW:
master^{commit}^{blob}throwsInvalidSpecificationExceptiontags/e90810b^{commit}^{blob}throwsInvalidSpecificationException/cc @carlosmn @jamill Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me. If an app cares about the difference between the errors, it can tell the user what went wrong more specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if the ability to discern between these two cases is actually worth the complexity of having two exceptions that are pretty similar (they both mean I can peel the object as requested). However, everything is working as designed in libgit2 - I wouldn't argue to change the current design unless we get feedback that this is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fits me