Error Reporting and Handling
Reporting Errors to the Component from Event Handlers
If the event has a ResultCode parameter, the event handler should use it to return the result code of the operation to the component. The ResultCode parameter is set to 0 by default, which indicates the operation was successful. If an problem occurs while handling the event, set the ResultCode parameter to one of the following values to inform the component about it:
RWRESULT_SUCCESS | 0x00000000 | Success.
Return if all data was successfully transferred. |
RWRESULT_PARTIAL | 0x00000080 | Partial success.
Return if some, but not all, data was successfully transferred. I.e., when BytesRead < BytesToRead (for ReadData), or BytesWritten < BytesToWrite (for WriteData). |
RWRESULT_RANGE_BEYOND_EOF | 0x00000081 | Requested range is beyond the end of the file (EOF).
For the ReadData event, returning this code indicates to the cache that there is no need to request data beyond (Position + BytesRead), and that the tail should be zeroed instead. |
RWRESULT_FILE_MODIFIED_EXTERNALLY | 0x00000082 | The specified file's size was modified externally. |
RWRESULT_FILE_MODIFIED_LOCALLY | 0x00000083 | The requested file's size was modified locally. |
RWRESULT_FAILURE | 0x0000008D | The operation failed for some transient reason.
Returning this code indicates that, while the current request failed, it is safe to continue sending requests for both the specified file and others. (Other operations may continue.) |
RWRESULT_FILE_FAILURE | 0x0000008E | The operation failed for some external-file-related reason.
Returning this code indicates that some failure related to the external file itself has occurred, and it is expected that any further requests made against that file will also fail. The component will not send any more requests for the specified file until the file-specific error is reset as described in Reporting Transport Errors. |
RWRESULT_PERMANENT_FAILURE | 0x0000008F | The operation failed for some external-storage-related reason.
Returning this code indicates that some failure related to the external storage itself has occurred, and it is expected that all further requests will also fail. The component will not send any more requests for any file until the global error is reset as described in Reporting Transport Errors. |
If an unhandled exception occurs in the event handler, it will be caught by the component, which will fire the OnError event.
How to Handle Errors Reported by the Component
The CBFS Cache component APIs communicate errors to applications using the error codes defined on the Error Codes page.
If an error occurs, the component will throw an exception. The Code property of the exception object will contain an error code, and the Message property will contain an error message (if available).