/// <summary>
 /// Initializes a new instance of the <see cref="BaseException" /> class. This is used internally for restoring exception instance from ExceptionInfo.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="createdStamp">The created stamp.</param>
 /// <param name="message">The message.</param>
 /// <param name="scene">The scene.</param>
 /// <param name="code">The code.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="operatorCredential">The operator credential.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 protected BaseException(Guid key, DateTime createdStamp, string message, ExceptionScene scene, ExceptionCode code, Exception innerException, BaseCredential operatorCredential, JToken data, FriendlyHint hint)
     : base(message, innerException)
 {
     Key                = key;
     CreatedStamp       = createdStamp;
     Scene              = scene;
     Code               = code;
     OperatorCredential = operatorCredential as BaseCredential;
     ReferenceData      = data;
     Hint               = hint;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InitializationFailureException" /> class.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="createdStamp">The created stamp.</param>
 /// <param name="message">The message.</param>
 /// <param name="scene">The scene.</param>
 /// <param name="code">The code.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="operatorCredential">The operator credential.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 internal InitializationFailureException(Guid key, DateTime createdStamp, string message, ExceptionScene scene, ExceptionCode code, Exception innerException, BaseCredential operatorCredential, JToken data, FriendlyHint hint)
     : base(key, createdStamp, message, scene, code, innerException, operatorCredential, data, hint)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InitializationFailureException" /> class.
 /// </summary>
 /// <param name="target">The object identity.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="minor">The minor.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public InitializationFailureException(string target, Exception innerException = null, string minor = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Failed to initialize [{0}].", target), new ExceptionCode {
     Major = ExceptionCode.MajorCode.ServiceUnavailable, Minor = minor.SafeToString("Initialize")
 }, innerException, data, hint, scene)
 {
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidObjectException" /> class.
 /// </summary>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="reason">The reason.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public InvalidObjectException(Exception innerException, object data = null, string reason = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base((innerException?.Message).SafeToString("Invalid object."), new ExceptionCode {
     Major = ExceptionCode.MajorCode.NullOrInvalidValue, Minor = reason.SafeToString("InvalidObject")
 }, innerException, data, hint, scene)
 {
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidObjectException" /> class.
 /// </summary>
 /// <param name="objectIdentity">The object identity.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="reason">The reason.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public InvalidObjectException(string objectIdentity, Exception innerException = null, object data = null, string reason = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Object [{0}] is invalid.", objectIdentity), new ExceptionCode {
     Major = ExceptionCode.MajorCode.NullOrInvalidValue, Minor = reason.SafeToString("InvalidObject")
 }, innerException, data, hint, scene)
 {
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidExpressiontException"/> class.
 /// </summary>
 /// <param name="expectObject">The expect object.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="position">The position.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public InvalidExpressiontException(string expectObject, Exception innerException = null, string data = null, int?position = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Expecting [{0}] when cast expression at position [{1}].", expectObject, position), new ExceptionCode {
     Major = ExceptionCode.MajorCode.NullOrInvalidValue, Minor = "InvalidExpression"
 }, innerException, data, hint, scene)
 {
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OperationFailureException" /> class.
 /// </summary>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="minor">The minor.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public OperationFailureException(Exception innerException = null, object data = null, string minor = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Failed to operate to [{0}].", scene?.MethodName), new ExceptionCode { Major = ExceptionCode.MajorCode.OperationFailure, Minor = minor }, innerException, data, hint, scene)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkflowOperationException" /> class.
 /// </summary>
 /// <param name="workflowName">Name of the workflow.</param>
 /// <param name="state">The state.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public WorkflowOperationException(string workflowName, string state, Exception innerException = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Operation [{0}] on workflow [{1}] is forbidden due to state [{2}] against the workflow.", scene?.MethodName, workflowName, state),
            new ExceptionCode {
     Major = ExceptionCode.MajorCode.OperationForbidden, Minor = "Workflow"
 }, innerException, data, hint, scene)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreditNotAffordException" /> class.
 /// </summary>
 /// <param name="resourceName">Name of the resource.</param>
 /// <param name="resourceIdentifier">The resource identifier.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="minor">The minor.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public CreditNotAffordException(string resourceName, string resourceIdentifier, Exception innerException = null, string minor = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Credit is not afford for resource [{0}] at [{1}].", resourceName, resourceIdentifier), new ExceptionCode {
     Major = ExceptionCode.MajorCode.CreditNotAfford, Minor = minor.SafeToString(resourceName)
 }, innerException, data, hint, scene)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataConflictException" /> class.
 /// </summary>
 /// <param name="entityName">Name of the entity.</param>
 /// <param name="objectIdentity">The object identity.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public DataConflictException(string entityName, string objectIdentity = null, Exception innerException = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Data conflicts for [{0}] at [{1}]", entityName, objectIdentity), new ExceptionCode {
     Major = ExceptionCode.MajorCode.DataConflict, Minor = entityName
 }, innerException, data, hint, scene)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OperationForbiddenException"/> class.
 /// </summary>
 /// <param name="reason">The reason.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="actionName">Name of the action.</param>
 public OperationForbiddenException(string reason, Exception innerException = null, object data = null, FriendlyHint hint = null, [CallerMemberName] string actionName = null)
     : base(string.Format("Operation [{0}] is forbidden. Reason: {1}", actionName, reason), new ExceptionCode {
     Major = ExceptionCode.MajorCode.OperationForbidden, Minor = reason
 }, innerException, data, hint, null)
 {
 }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseException" /> class.
        /// </summary>
        /// <param name="message">The exception message.</param>
        /// <param name="code">The exception code.</param>
        /// <param name="innerException">The inner exception.</param>
        /// <param name="data">The data.</param>
        /// <param name="hint">The hint.</param>
        /// <param name="scene">The scene.</param>
        protected BaseException(string message, ExceptionCode code, Exception innerException = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
            : base(message, innerException)
        {
            Code = code;
            OperatorCredential = Framework.GetCurrentOperatorCredential?.Invoke();
            ReferenceData      = data == null ? null : JToken.FromObject(data);
            Scene        = scene;
            CreatedStamp = DateTime.UtcNow;

            var inner = innerException as BaseException;

            Key = inner == null?Guid.NewGuid() : inner.Key;

            Hint = hint ?? inner?.Hint;
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceNotFoundException" /> class.
 /// </summary>
 /// <param name="resourceName">Name of the resource.</param>
 /// <param name="friendlyHint">The friendly hint.</param>
 /// <param name="scene">The scene.</param>
 public ResourceNotFoundException(string resourceName, FriendlyHint friendlyHint = null, ExceptionScene scene = null)
     : base(string.Format("Resource [{0}] is not found.", resourceName), new ExceptionCode {
     Major = ExceptionCode.MajorCode.ResourceNotFound
 }, hint: friendlyHint, scene: scene)
 {
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnauthorizedOperationException" /> class.
 /// </summary>
 /// <param name="minorCode">The reason.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="operationName">Name of the operation.</param>
 public UnauthorizedOperationException(string minorCode = null, object data = null, FriendlyHint hint = null, [CallerMemberName] string operationName = null)
     : base(string.Format("Unauthorized operation on [{0}].", operationName),
            new ExceptionCode {
     Major = ExceptionCode.MajorCode.UnauthorizedOperation, Minor = minorCode.SafeToString("Operation")
 }, data: data, hint: hint)
 {
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnauthorizedOperationException" /> class.
 /// </summary>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="minorCode">The minor code.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public UnauthorizedOperationException(Exception innerException, string minorCode = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("Unauthorized operation on [{0}].", scene?.MethodName),
            new ExceptionCode {
     Major = ExceptionCode.MajorCode.UnauthorizedOperation, Minor = minorCode.SafeToString("Operation")
 }, innerException, data, hint, scene)
 {
 }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnsupportedException" /> class.
 /// </summary>
 /// <param name="objectIdentifier">The object identifier.</param>
 /// <param name="innerException">The inner exception.</param>
 /// <param name="reason">The reason.</param>
 /// <param name="data">The data.</param>
 /// <param name="hint">The hint.</param>
 /// <param name="scene">The scene.</param>
 public UnsupportedException(string objectIdentifier, Exception innerException = null, string reason = null, object data = null, FriendlyHint hint = null, ExceptionScene scene = null)
     : base(string.Format("[{0}] is not supported .", objectIdentifier), new ExceptionCode {
     Major = ExceptionCode.MajorCode.CreditNotAfford, Minor = reason
 }, innerException, data, hint, scene)
 {
 }