diff --git a/src/Agent/API.md b/src/Agent/API.md
index 994695c7..7e8fa49d 100644
--- a/src/Agent/API.md
+++ b/src/Agent/API.md
@@ -108,11 +108,14 @@
- [#ctor(message)](#M-EdjCase-ICP-Agent-InvalidCertificateException-#ctor-System-String- 'EdjCase.ICP.Agent.InvalidCertificateException.#ctor(System.String)')
- [InvalidPublicKey](#T-EdjCase-ICP-Agent-InvalidPublicKey 'EdjCase.ICP.Agent.InvalidPublicKey')
- [#ctor()](#M-EdjCase-ICP-Agent-InvalidPublicKey-#ctor 'EdjCase.ICP.Agent.InvalidPublicKey.#ctor')
+- [QueryRejectInfo](#T-EdjCase-ICP-Agent-Responses-QueryRejectInfo 'EdjCase.ICP.Agent.Responses.QueryRejectInfo')
+ - [Code](#P-EdjCase-ICP-Agent-Responses-QueryRejectInfo-Code 'EdjCase.ICP.Agent.Responses.QueryRejectInfo.Code')
+ - [ErrorCode](#P-EdjCase-ICP-Agent-Responses-QueryRejectInfo-ErrorCode 'EdjCase.ICP.Agent.Responses.QueryRejectInfo.ErrorCode')
+ - [Message](#P-EdjCase-ICP-Agent-Responses-QueryRejectInfo-Message 'EdjCase.ICP.Agent.Responses.QueryRejectInfo.Message')
- [QueryRejectedException](#T-EdjCase-ICP-Agent-QueryRejectedException 'EdjCase.ICP.Agent.QueryRejectedException')
- - [#ctor(code,message)](#M-EdjCase-ICP-Agent-QueryRejectedException-#ctor-EdjCase-ICP-Agent-Responses-RejectCode,System-String- 'EdjCase.ICP.Agent.QueryRejectedException.#ctor(EdjCase.ICP.Agent.Responses.RejectCode,System.String)')
- - [Code](#P-EdjCase-ICP-Agent-QueryRejectedException-Code 'EdjCase.ICP.Agent.QueryRejectedException.Code')
+ - [#ctor(info)](#M-EdjCase-ICP-Agent-QueryRejectedException-#ctor-EdjCase-ICP-Agent-Responses-QueryRejectInfo- 'EdjCase.ICP.Agent.QueryRejectedException.#ctor(EdjCase.ICP.Agent.Responses.QueryRejectInfo)')
+ - [Info](#P-EdjCase-ICP-Agent-QueryRejectedException-Info 'EdjCase.ICP.Agent.QueryRejectedException.Info')
- [Message](#P-EdjCase-ICP-Agent-QueryRejectedException-Message 'EdjCase.ICP.Agent.QueryRejectedException.Message')
- - [RejectionMessage](#P-EdjCase-ICP-Agent-QueryRejectedException-RejectionMessage 'EdjCase.ICP.Agent.QueryRejectedException.RejectionMessage')
- [QueryReply](#T-EdjCase-ICP-Agent-Responses-QueryReply 'EdjCase.ICP.Agent.Responses.QueryReply')
- [Arg](#P-EdjCase-ICP-Agent-Responses-QueryReply-Arg 'EdjCase.ICP.Agent.Responses.QueryReply.Arg')
- [QueryRequest](#T-EdjCase-ICP-Agent-Requests-QueryRequest 'EdjCase.ICP.Agent.Requests.QueryRequest')
@@ -1480,6 +1483,38 @@ Exception to indicate that the specified BLS public key is invalid
This constructor has no parameters.
+
+## QueryRejectInfo `type`
+
+##### Namespace
+
+EdjCase.ICP.Agent.Responses
+
+##### Summary
+
+Data from a query response that has been rejected
+
+
+### Code `property`
+
+##### Summary
+
+The type of query reject
+
+
+### ErrorCode `property`
+
+##### Summary
+
+Optional. A specific error id for the reject
+
+
+### Message `property`
+
+##### Summary
+
+Optional. A human readable message about the rejection
+
## QueryRejectedException `type`
@@ -1491,22 +1526,21 @@ EdjCase.ICP.Agent
Exception for when a query to a canister is rejected/has an error
-
-### #ctor(code,message) `constructor`
+
+### #ctor(info) `constructor`
##### Parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
-| code | [EdjCase.ICP.Agent.Responses.RejectCode](#T-EdjCase-ICP-Agent-Responses-RejectCode 'EdjCase.ICP.Agent.Responses.RejectCode') | The type of rejection that occurred |
-| message | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The human readable message of the rejection error |
+| info | [EdjCase.ICP.Agent.Responses.QueryRejectInfo](#T-EdjCase-ICP-Agent-Responses-QueryRejectInfo 'EdjCase.ICP.Agent.Responses.QueryRejectInfo') | The type of rejection that occurred |
-
-### Code `property`
+
+### Info `property`
##### Summary
-The type of rejection that occurred
+The details of the rejection
### Message `property`
@@ -1515,13 +1549,6 @@ The type of rejection that occurred
*Inherit from parent.*
-
-### RejectionMessage `property`
-
-##### Summary
-
-The human readable message of the rejection error
-
## QueryReply `type`
diff --git a/src/Agent/API.xml b/src/Agent/API.xml
index faec18e3..b11caa93 100644
--- a/src/Agent/API.xml
+++ b/src/Agent/API.xml
@@ -306,19 +306,13 @@
Exception for when a query to a canister is rejected/has an error
-
+
- The type of rejection that occurred
-
-
-
-
- The human readable message of the rejection error
+ The details of the rejection
-
- The type of rejection that occurred
- The human readable message of the rejection error
+
+ The type of rejection that occurred
@@ -847,6 +841,26 @@
The candid arg returned from a request
+
+
+ Data from a query response that has been rejected
+
+
+
+
+ The type of query reject
+
+
+
+
+ Optional. A human readable message about the rejection
+
+
+
+
+ Optional. A specific error id for the reject
+
+
Model for a reponse to a read state request
diff --git a/src/Agent/Cbor/Converters/QueryResponseCborConverter.cs b/src/Agent/Cbor/Converters/QueryResponseCborConverter.cs
index 85db2f88..02d559e7 100644
--- a/src/Agent/Cbor/Converters/QueryResponseCborConverter.cs
+++ b/src/Agent/Cbor/Converters/QueryResponseCborConverter.cs
@@ -26,7 +26,7 @@ public override QueryResponse Read(ref CborReader reader)
return QueryResponse.Replied(reply);
case "rejected":
RejectCode code = (RejectCode)(ulong)context.RejectCode!;
- return QueryResponse.Rejected(code, context.RejectMessage);
+ return QueryResponse.Rejected(code, context.RejectMessage, context.ErrorCode);
default:
throw new NotImplementedException($"Cannot deserialize query response with status '{context.Status}'");
}
@@ -63,6 +63,9 @@ private void SetQueryResponseField(string name, ref CborReader reader, ref Query
case "reject_message":
context.RejectMessage = reader.ReadString();
break;
+ case "error_code":
+ context.ErrorCode = reader.ReadString();
+ break;
default:
throw new NotImplementedException($"Cannot deserialize query response. Unknown field '{name}'");
}
@@ -93,5 +96,6 @@ internal class QueryReponseContext
public byte[]? ReplyArg { get; set; }
public UnboundedUInt? RejectCode { get; set; }
public string? RejectMessage { get; set; }
+ public string? ErrorCode { get; set; }
}
}
diff --git a/src/Agent/Exceptions.cs b/src/Agent/Exceptions.cs
index aec1e278..cabf246b 100644
--- a/src/Agent/Exceptions.cs
+++ b/src/Agent/Exceptions.cs
@@ -78,24 +78,17 @@ public CallRejectedException(RejectCode rejectCode, string rejectMessage, string
public class QueryRejectedException : Exception
{
///
- /// The type of rejection that occurred
- ///
- public RejectCode Code { get; }
-
- ///
- /// The human readable message of the rejection error
+ /// The details of the rejection
///
- public string? RejectionMessage { get; }
+ public QueryRejectInfo Info { get; }
- /// The type of rejection that occurred
- /// The human readable message of the rejection error
- public QueryRejectedException(RejectCode code, string? message)
+ /// The type of rejection that occurred
+ internal QueryRejectedException(QueryRejectInfo info)
{
- this.Code = code;
- this.RejectionMessage = message;
+ this.Info = info;
}
///
- public override string Message => $"Query was rejected. Code: {this.Code}, Message: {this.Message}";
+ public override string Message => $"Query was rejected. Code: {this.Info.Code}, Message: {this.Info.Message}, ErrorCode: {this.Info.ErrorCode}";
}
}
diff --git a/src/Agent/Responses/QueryResponse.cs b/src/Agent/Responses/QueryResponse.cs
index fd2214b9..9b556df1 100644
--- a/src/Agent/Responses/QueryResponse.cs
+++ b/src/Agent/Responses/QueryResponse.cs
@@ -37,10 +37,10 @@ public QueryReply AsReplied()
///
/// Will throw if not of type 'rejected'
/// Reject error information
- public (RejectCode Code, string? Message) AsRejected()
+ public QueryRejectInfo AsRejected()
{
this.ThrowIfWrongType(QueryResponseType.Rejected);
- return (ValueTuple)this.value;
+ return (QueryRejectInfo)this.value;
}
private void ThrowIfWrongType(QueryResponseType type)
@@ -61,15 +61,15 @@ public QueryReply ThrowOrGetReply()
{
if (this.Type == QueryResponseType.Rejected)
{
- (RejectCode code, string? message) = this.AsRejected();
- throw new QueryRejectedException(code, message);
+ QueryRejectInfo rejectInfo = this.AsRejected();
+ throw new QueryRejectedException(rejectInfo);
}
return this.AsReplied();
}
- internal static QueryResponse Rejected(RejectCode code, string? message)
+ internal static QueryResponse Rejected(RejectCode code, string? message, string? errorCode)
{
- return new QueryResponse(QueryResponseType.Rejected, (code, message));
+ return new QueryResponse(QueryResponseType.Rejected, new QueryRejectInfo(code, message, errorCode));
}
internal static QueryResponse Replied(QueryReply reply)
@@ -109,4 +109,31 @@ internal QueryReply(CandidArg arg)
}
}
+ ///
+ /// Data from a query response that has been rejected
+ ///
+ public class QueryRejectInfo
+ {
+ ///
+ /// The type of query reject
+ ///
+ public RejectCode Code { get; }
+
+ ///
+ /// Optional. A human readable message about the rejection
+ ///
+ public string? Message { get; }
+
+ ///
+ /// Optional. A specific error id for the reject
+ ///
+ public string? ErrorCode { get; }
+
+ internal QueryRejectInfo(RejectCode code, string? message, string? errorCode)
+ {
+ this.Code = code;
+ this.Message = message;
+ this.ErrorCode = errorCode;
+ }
+ }
}
\ No newline at end of file