mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-27 00:23:39 +00:00
extract specific exception for when invalid paths raised
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
#if !NETFX_CORE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class RepositoryFormatException : Exception
|
||||
{
|
||||
readonly string message;
|
||||
|
||||
public RepositoryFormatException(IEnumerable<string> invalidRepositories)
|
||||
{
|
||||
var parameterList = string.Join(", ", invalidRepositories);
|
||||
message = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"The list of repositories must be formatted as 'owner/name' - these values don't match this rule: {0}",
|
||||
parameterList);
|
||||
|
||||
}
|
||||
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
/// <summary>
|
||||
/// Constructs an instance of LoginAttemptsExceededException
|
||||
/// </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 RepositoryFormatException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
if (info == null) return;
|
||||
message = info.GetString("Message");
|
||||
}
|
||||
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("Message", Message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -396,6 +396,7 @@
|
||||
<Compile Include="Exceptions\TwoFactorAuthorizationException.cs" />
|
||||
<Compile Include="Http\HttpMessageHandlerFactory.cs" />
|
||||
<Compile Include="Models\Response\TeamMembership.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -412,6 +412,7 @@
|
||||
<Compile Include="Models\Request\RepositoryHookTestRequest.cs" />
|
||||
<Compile Include="Http\HttpMessageHandlerFactory.cs" />
|
||||
<Compile Include="Models\Response\TeamMembership.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -405,6 +405,7 @@
|
||||
<Compile Include="Models\Request\RepositoryHookTestRequest.cs" />
|
||||
<Compile Include="Http\HttpMessageHandlerFactory.cs" />
|
||||
<Compile Include="Models\Response\TeamMembership.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -394,6 +394,7 @@
|
||||
<Compile Include="Exceptions\TwoFactorAuthorizationException.cs" />
|
||||
<Compile Include="Http\HttpMessageHandlerFactory.cs" />
|
||||
<Compile Include="Models\Response\TeamMembership.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -398,6 +398,7 @@
|
||||
<Compile Include="Exceptions\TwoFactorAuthorizationException.cs" />
|
||||
<Compile Include="Http\HttpMessageHandlerFactory.cs" />
|
||||
<Compile Include="Models\Response\TeamMembership.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
<Compile Include="Exceptions\TwoFactorAuthorizationException.cs" />
|
||||
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
||||
<Compile Include="Helpers\ApiUrls.Authorizations.cs" />
|
||||
|
||||
Reference in New Issue
Block a user