-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#255 - Throw exception when server API version is not supported.
- Loading branch information
Showing
5 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Money.Services | ||
{ | ||
public class ApiVersionChecker | ||
{ | ||
public bool IsPassed(Version version) | ||
{ | ||
// TODO: Check for compatibility. | ||
return false; | ||
} | ||
|
||
public void Ensure(Version version) | ||
{ | ||
if (!IsPassed(version)) | ||
throw new NotSupportedApiVersionException(version); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Money.UI.Blazor/Services/NotSupportedApiVersionException.cs
This file contains 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,40 @@ | ||
using Neptuo; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Money.Services | ||
{ | ||
/// <summary> | ||
/// Exception raised when server API is not supported by the current client version. | ||
/// </summary> | ||
[Serializable] | ||
public class NotSupportedApiVersionException : Exception | ||
{ | ||
public Version ApiVersion { get; } | ||
|
||
/// <summary> | ||
/// Creates a new instance with server api version. | ||
/// </summary> | ||
/// <param name="apiVersion">The server API version.</param> | ||
public NotSupportedApiVersionException(Version apiVersion) | ||
: base($"Server API version is 'v{apiVersion}' which is not support by current client version.") | ||
{ | ||
Ensure.NotNull(apiVersion, "apiVersion"); | ||
ApiVersion = apiVersion; | ||
} | ||
|
||
/// <summary> | ||
/// Creates new instance for deserialization. | ||
/// </summary> | ||
/// <param name="info">The serialization info.</param> | ||
/// <param name="context">The streaming context.</param> | ||
protected NotSupportedApiVersionException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ } | ||
} | ||
} |