diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceErrorInfo.cs b/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceErrorInfo.cs new file mode 100644 index 0000000000..bfe6af3aa2 --- /dev/null +++ b/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceErrorInfo.cs @@ -0,0 +1,91 @@ +using System; + +namespace Volo.Abp.Http +{ + /// + /// Used to store information about an error. + /// + [Serializable] + public class RemoteServiceErrorInfo + { + /// + /// Error code. + /// + public int Code { get; set; } + + /// + /// Error message. + /// + public string Message { get; set; } + + /// + /// Error details. + /// + public string Details { get; set; } + + /// + /// Validation errors if exists. + /// + public RemoteServiceValidationErrorInfo[] ValidationErrors { get; set; } + + /// + /// Creates a new instance of . + /// + public RemoteServiceErrorInfo() + { + + } + + /// + /// Creates a new instance of . + /// + /// Error message + public RemoteServiceErrorInfo(string message) + { + Message = message; + } + + /// + /// Creates a new instance of . + /// + /// Error code + public RemoteServiceErrorInfo(int code) + { + Code = code; + } + + /// + /// Creates a new instance of . + /// + /// Error code + /// Error message + public RemoteServiceErrorInfo(int code, string message) + : this(message) + { + Code = code; + } + + /// + /// Creates a new instance of . + /// + /// Error message + /// Error details + public RemoteServiceErrorInfo(string message, string details) + : this(message) + { + Details = details; + } + + /// + /// Creates a new instance of . + /// + /// Error code + /// Error message + /// Error details + public RemoteServiceErrorInfo(int code, string message, string details) + : this(message, details) + { + Code = code; + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceErrorResponse.cs b/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceErrorResponse.cs new file mode 100644 index 0000000000..f2ecd1f591 --- /dev/null +++ b/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceErrorResponse.cs @@ -0,0 +1,12 @@ +namespace Volo.Abp.Http +{ + public abstract class RemoteServiceErrorResponse + { + public RemoteServiceErrorInfo Error { get; set; } + + /// + /// A special signature of ABP. + /// + public bool __abp { get; } = true; + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs b/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs new file mode 100644 index 0000000000..1a84ae2c29 --- /dev/null +++ b/src/Volo.Abp.Http/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs @@ -0,0 +1,60 @@ +using System; + +namespace Volo.Abp.Http +{ + /// + /// Used to store information about a validation error. + /// + [Serializable] + public class RemoteServiceValidationErrorInfo + { + /// + /// Validation error message. + /// + public string Message { get; set; } + + /// + /// Relate invalid members (fields/properties). + /// + public string[] Members { get; set; } + + /// + /// Creates a new instance of . + /// + public RemoteServiceValidationErrorInfo() + { + + } + + /// + /// Creates a new instance of . + /// + /// Validation error message + public RemoteServiceValidationErrorInfo(string message) + { + Message = message; + } + + /// + /// Creates a new instance of . + /// + /// Validation error message + /// Related invalid members + public RemoteServiceValidationErrorInfo(string message, string[] members) + : this(message) + { + Members = members; + } + + /// + /// Creates a new instance of . + /// + /// Validation error message + /// Related invalid member + public RemoteServiceValidationErrorInfo(string message, string member) + : this(message, new[] { member }) + { + + } + } +} \ No newline at end of file