Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 2a7643c

Browse files
committed
Add default exception constructors
1 parent e6166ca commit 2a7643c

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

src/GitHub.Api/Application/ApiClient.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading.Tasks;
55
using Octokit;
6+
using System.Runtime.Serialization;
67

78
namespace GitHub.Unity
89
{
@@ -333,7 +334,7 @@ class GitHubRepository
333334
}
334335

335336
[Serializable]
336-
class ApiClientException : Exception
337+
public class ApiClientException : Exception
337338
{
338339
public ApiClientException()
339340
{ }
@@ -343,6 +344,9 @@ public ApiClientException(string message) : base(message)
343344

344345
public ApiClientException(string message, Exception innerException) : base(message, innerException)
345346
{ }
347+
348+
protected ApiClientException(SerializationInfo info, StreamingContext context) : base(info, context)
349+
{ }
346350
}
347351

348352
[Serializable]
@@ -356,12 +360,22 @@ public TokenUsernameMismatchException(string cachedUsername, string currentUsern
356360
CachedUsername = cachedUsername;
357361
CurrentUsername = currentUsername;
358362
}
363+
protected TokenUsernameMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
364+
{ }
359365
}
360366

361367
[Serializable]
362368
class KeychainEmptyException : ApiClientException
363369
{
364370
public KeychainEmptyException()
365371
{ }
372+
public KeychainEmptyException(string message) : base(message)
373+
{ }
374+
375+
public KeychainEmptyException(string message, Exception innerException) : base(message, innerException)
376+
{ }
377+
378+
protected KeychainEmptyException(SerializationInfo info, StreamingContext context) : base(info, context)
379+
{ }
366380
}
367381
}

src/GitHub.Api/Helpers/Guard.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Globalization;
44
using System.Linq;
5+
using System.Runtime.Serialization;
56

67
namespace GitHub.Unity
78
{
@@ -11,6 +12,9 @@ internal class InstanceNotInitializedException : InvalidOperationException
1112
public InstanceNotInitializedException(object the, string property) :
1213
base(String.Format(CultureInfo.InvariantCulture, "{0} is not correctly initialized, {1} is null", the?.GetType().Name, property))
1314
{}
15+
16+
protected InstanceNotInitializedException(SerializationInfo info, StreamingContext context) : base(info, context)
17+
{ }
1418
}
1519

1620
internal static class Guard

src/GitHub.Api/Helpers/TaskHelpers.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Runtime.Serialization;
23
using System.Threading.Tasks;
34

45
namespace GitHub.Unity
@@ -21,5 +22,13 @@ public static Task<T> ToTask<T>(this Exception exception)
2122
[Serializable]
2223
public class NotReadyException : Exception
2324
{
25+
public NotReadyException() : base()
26+
{ }
27+
public NotReadyException(string message) : base(message)
28+
{ }
29+
public NotReadyException(string message, Exception innerException) : base(message, innerException)
30+
{ }
31+
protected NotReadyException(SerializationInfo info, StreamingContext context) : base(info, context)
32+
{ }
2433
}
2534
}
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
11
using System;
2+
using System.Runtime.Serialization;
23
using System.Threading.Tasks;
34

45
namespace GitHub.Unity
56
{
67
[Serializable]
78
class DependentTaskFailedException : TaskCanceledException
89
{
9-
public DependentTaskFailedException(ITask task, Exception ex) : base(ex.InnerException != null ? ex.InnerException.Message : ex.Message, ex.InnerException ?? ex)
10+
protected DependentTaskFailedException() : base()
11+
{ }
12+
protected DependentTaskFailedException(string message) : base(message)
13+
{ }
14+
protected DependentTaskFailedException(string message, Exception innerException) : base(message, innerException)
15+
{ }
16+
protected DependentTaskFailedException(SerializationInfo info, StreamingContext context) : base(info, context)
17+
{ }
18+
19+
public DependentTaskFailedException(ITask task, Exception ex) : this(ex.InnerException != null ? ex.InnerException.Message : ex.Message, ex.InnerException ?? ex)
1020
{}
1121
}
1222

1323
[Serializable]
1424
class ProcessException : TaskCanceledException
1525
{
16-
public ProcessException(ITask process) : base(process.Errors)
26+
protected ProcessException() : base()
27+
{ }
28+
protected ProcessException(string message) : base(message)
29+
{ }
30+
protected ProcessException(string message, Exception innerException) : base(message, innerException)
31+
{ }
32+
protected ProcessException(SerializationInfo info, StreamingContext context) : base(info, context)
33+
{ }
34+
35+
public ProcessException(ITask process) : this(process.Errors)
1736
{ }
1837
}
1938
}

0 commit comments

Comments
 (0)