-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from MonacsLib/develop
Monacs v.0.2.0
- Loading branch information
Showing
17 changed files
with
992 additions
and
392 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,70 @@ | ||
using System; | ||
using static Monacs.Core.Option; | ||
|
||
namespace Monacs.Core | ||
{ | ||
/// <summary> | ||
/// Contains factory methods to create instances of <see cref="ErrorDetails"/> in a more convenient way. | ||
/// </summary> | ||
public static class Errors | ||
{ | ||
public static ErrorDetails Trace(string message = null, string key = null, Exception exception = null) => | ||
new ErrorDetails(ErrorLevel.Trace, message.ToOption(), key.ToOption(), exception.ToOption()); | ||
/// <summary> | ||
/// Creates <see cref="ErrorDetails"/> with level <see cref="ErrorLevel.Trace"/>. | ||
/// </summary> | ||
/// <param name="message">Optional error message</param> | ||
/// <param name="key">Optional key to identify the error</param> | ||
/// <param name="exception">Optional exception which caused the error</param> | ||
/// <param name="metadata">Optional error metadata</param> | ||
public static ErrorDetails Trace(string message = null, string key = null, Exception exception = null, object metadata = null) => | ||
new ErrorDetails(ErrorLevel.Trace, message.ToOption(), key.ToOption(), exception.ToOption(), metadata.ToOption()); | ||
|
||
public static ErrorDetails Debug(string message = null, string key = null, Exception exception = null) => | ||
new ErrorDetails(ErrorLevel.Debug, message.ToOption(), key.ToOption(), exception.ToOption()); | ||
/// <summary> | ||
/// Creates <see cref="ErrorDetails"/> with level <see cref="ErrorLevel.Debug"/>. | ||
/// </summary> | ||
/// <param name="message">Optional error message</param> | ||
/// <param name="key">Optional key to identify the error</param> | ||
/// <param name="exception">Optional exception which caused the error</param> | ||
/// <param name="metadata">Optional error metadata</param> | ||
public static ErrorDetails Debug(string message = null, string key = null, Exception exception = null, object metadata = null) => | ||
new ErrorDetails(ErrorLevel.Debug, message.ToOption(), key.ToOption(), exception.ToOption(), metadata.ToOption()); | ||
|
||
public static ErrorDetails Info(string message = null, string key = null, Exception exception = null) => | ||
new ErrorDetails(ErrorLevel.Info, message.ToOption(), key.ToOption(), exception.ToOption()); | ||
/// <summary> | ||
/// Creates <see cref="ErrorDetails"/> with level <see cref="ErrorLevel.Info"/>. | ||
/// </summary> | ||
/// <param name="message">Optional error message</param> | ||
/// <param name="key">Optional key to identify the error</param> | ||
/// <param name="exception">Optional exception which caused the error</param> | ||
/// <param name="metadata">Optional error metadata</param> | ||
public static ErrorDetails Info(string message = null, string key = null, Exception exception = null, object metadata = null) => | ||
new ErrorDetails(ErrorLevel.Info, message.ToOption(), key.ToOption(), exception.ToOption(), metadata.ToOption()); | ||
|
||
public static ErrorDetails Warn(string message = null, string key = null, Exception exception = null) => | ||
new ErrorDetails(ErrorLevel.Warn, message.ToOption(), key.ToOption(), exception.ToOption()); | ||
/// <summary> | ||
/// Creates <see cref="ErrorDetails"/> with level <see cref="ErrorLevel.Warn"/>. | ||
/// </summary> | ||
/// <param name="message">Optional error message</param> | ||
/// <param name="key">Optional key to identify the error</param> | ||
/// <param name="exception">Optional exception which caused the error</param> | ||
/// <param name="metadata">Optional error metadata</param> | ||
public static ErrorDetails Warn(string message = null, string key = null, Exception exception = null, object metadata = null) => | ||
new ErrorDetails(ErrorLevel.Warn, message.ToOption(), key.ToOption(), exception.ToOption(), metadata.ToOption()); | ||
|
||
public static ErrorDetails Error(string message = null, string key = null, Exception exception = null) => | ||
new ErrorDetails(ErrorLevel.Error, message.ToOption(), key.ToOption(), exception.ToOption()); | ||
/// <summary> | ||
/// Creates <see cref="ErrorDetails"/> with level <see cref="ErrorLevel.Error"/>. | ||
/// </summary> | ||
/// <param name="message">Optional error message</param> | ||
/// <param name="key">Optional key to identify the error</param> | ||
/// <param name="exception">Optional exception which caused the error</param> | ||
/// <param name="metadata">Optional error metadata</param> | ||
public static ErrorDetails Error(string message = null, string key = null, Exception exception = null, object metadata = null) => | ||
new ErrorDetails(ErrorLevel.Error, message.ToOption(), key.ToOption(), exception.ToOption(), metadata.ToOption()); | ||
|
||
public static ErrorDetails Fatal(string message = null, string key = null, Exception exception = null) => | ||
new ErrorDetails(ErrorLevel.Fatal, message.ToOption(), key.ToOption(), exception.ToOption()); | ||
/// <summary> | ||
/// Creates <see cref="ErrorDetails"/> with level <see cref="ErrorLevel.Fatal"/>. | ||
/// </summary> | ||
/// <param name="message">Optional error message</param> | ||
/// <param name="key">Optional key to identify the error</param> | ||
/// <param name="exception">Optional exception which caused the error</param> | ||
/// <param name="metadata">Optional error metadata</param> | ||
public static ErrorDetails Fatal(string message = null, string key = null, Exception exception = null, object metadata = null) => | ||
new ErrorDetails(ErrorLevel.Fatal, message.ToOption(), key.ToOption(), exception.ToOption(), metadata.ToOption()); | ||
} | ||
} |
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
Oops, something went wrong.