ErrorArchive
Entity Properties¶
Each entity in the ErrorArchive
entity set has the following properties:
Name | Type | Description |
---|---|---|
RequestID |
Edm.Int64 |
An incrementing unique integer assigned to each request. |
CustomTag |
Edm.String |
The value of the custom tag field of the offending request (if a value for the custom tag field was specified when sending the request). |
HTTPStatusCode |
Edm.Int32 |
The HTTP status code returned in the response of the OData service. |
Code |
Edm.String |
The vendor error code returned in the response of the OData service. |
Message |
Edm.String |
The vendor error message returned in the response of the OData service. |
InnerError |
Edm.String |
The vendor inner error returned in the response of the OData service. |
Domain |
Edm.String |
The domain of the error. |
RequestMethod |
Edm.String |
The HTTP method of the offending request (POST , PUT , PATCH , DELETE , and so on). |
RequestURL |
Edm.String |
The URL of the offending request. |
RequestBody |
Edm.String |
The payload of the offending request. |
AffectedEntity |
Navigation Property | A navigation property that navigates from an ErrorArchive entity to an entity in the offline store that is affected by the error. |
The following code example shows how to access ErrorArchive
(if some errors have occurred) using the dynamic API:
// Set up the entity set, entity type, and properties for ErrorArchive
EntitySet errorArchiveSet = eventService.getEntitySet("ErrorArchive");
EntityType errorArchiveType = errorArchiveSet.getEntityType();
// Navigation property
Property affectedEntityProp = errorArchiveType.getProperty("AffectedEntity");
// Structural properties
Property requestIDProp = errorArchiveType.getProperty("RequestID");
Property requestBodyProp = errorArchiveType.getProperty("RequestBody");
Property httpStatusCodeProp = errorArchiveType.getProperty("HTTPStatusCode");
Property codeProp = errorArchiveType.getProperty("Code");
Property messageProp = errorArchiveType.getProperty("Message");
Property requestMethodProp = errorArchiveType.getProperty("RequestMethod");
Property requestURLProp = errorArchiveType.getProperty("RequestURL");
DataQuery errorArchiveQuery = new DataQuery().from(errorArchiveSet);
// See if there are any errors in the ErrorArchive
long nErrors = eventService.executeQuery(errorArchiveQuery).getCount();
// Get the list of errors in the ErrorArchive
EntityValueList errors = eventService.executeQuery(errorArchiveQuery).getEntityList();
// Examine the first error entry
EntityValue error = errors.get(0);
// Check for Http Status Code returned
int httpStatusCoce = httpStatusCodeProp.getInt(error));
// Error message
String message = messageProp.getString(error);
// Request method: POST, PUT, DELETE, et cetera
String requestMethod = requestMethodProp.getString(error);
// Request URL (OData request)
String requestURL = requestURLProp.getString(error);
/// Set up entity set, entity type and properties for ErrorArchive
let errorArchiveSet: EntitySet = eventService.entitySet(withName: "ErrorArchive")
let errorArchiveType: EntityType = errorArchiveSet.entityType
/// Navigation property
let affectedEntityProp = errorArchiveType.property(withName: "AffectedEntity")
/// Structural properties
let requestIDProp = errorArchiveType.property(withName: "RequestID")
let requestBodyProp = errorArchiveType.property(withName: "RequestBody")
let httpStatusCodeProp = errorArchiveType.property(withName: "HTTPStatusCode")
let codeProp = errorArchiveType.property(withName: "Code")
let messageProp = errorArchiveType.property(withName: "Message")
let requestMethodProp = errorArchiveType.property(withName: "RequestMethod")
let requestURLProp = errorArchiveType.property(withName: "RequestURL")
let errorArchiveQuery = DataQuery().from(errorArchiveSet)
/// See if there are any errors in the ErrorArchive entity set
let nErrors = try eventService.executeQuery(errorArchiveQuery).count()
/// Get the list of errors in the ErrorArchive entity set
let errors = try eventService.executeQuery(errorArchiveQuery).entityList()
/// Examine the first error entry (giving that there is at least one error)
let error = errors.first()
/// Get request ID
let requestID = requestIDProp.longValue(from: error)
/// Get request body
let requestBody = requestBodyProp.stringValue(from: error)
/// Get Http Status Code returned
let httpStatusCoce = httpStatusCodeProp.intValue(from: error)
/// Get error code returned
let code = codeProp.stringValue(from: error)
/// Get error message
let message = messageProp.stringValue(from: error)
/// Get request method: POST, PUT, DELETE, et cetera
let requestMethod = requestMethodProp.stringValue(from: error)
/// Get request URL (OData request)
let requestURL = requestURLProp.stringValue(from: error)
/// Use the values
...
The sample below shows how to access ErrorArchive
using OfflineODataProvider
(only for Java source code)and the built-in proxy class OfflineODataErrorArchiveEntity
.
// Get entities from the ErrorArchive entity set
List<OfflineODataErrorArchiveEntity> errorArchiveEntities = provider.getErrorArchive();
// Access each error
for (OfflineODataErrorArchiveEntity entity : errorArchiveEntities) {
long id = entity.getRequestID();
String requestBody = entity.getRequestBody();
// Use the values
...
}
/// Get ErrorArchive entities. The type of the result is Array<OfflineODataErrorArchiveEntity>
try errorArchiveEntities = try eventService.fetchErrorArchive()
/// Access the entities (if some errors have occurred)
for error in errorArchiveEntities {
let requestID = error.requestID
let requestBody = error.requestBody ?? ""
/// Use the values
...
}
Note that property names from the proxy class are slightly different from what you use in the dynamic API. For example, when using the dynamic API, you can access a property named RequestID
. When using the proxy class, the property name is requestID
.
Last update: June 7, 2022