Skip to content

HandleCacheError - cDbCJGrid

Called when the grid cannot find a cached record on the back end and pbCacheError = True

Type: Procedure

Syntax

Procedure HandleCacheError

Call Example

Send HandleCacheError

Description

This method is called when the grid cannot find a cached record on the back end and has set pbCacheError to True. This is used to handle the error. It normally reports a handled error.

If pbSuppressCacheError is set to True, no error is reported. When pbSuppressCacheError is set to False (the default), it will call the method ReportCacheError, which raises the handled DFERR_CANT_REFIND_RECORD error.

Next, this method will attempt to refresh the grid's cache based around the current record. Note that the cache error usually occurs when navigating from a valid current record to some other record. If the grid cannot be refreshed around the current record, it refreshes the grid from the top.

This method can be augmented or overridden, but you must make sure that any customization handles the error and refreshes the grid with valid records. If you are going to augment or override this method, you are encouraged to first study the code in the package.

HandleCacheError may be called for expected and unexpected reasons. In a multi-user environment, a record may get deleted or a record may be changed, in a way that makes it constraint invalid. This is expected and is what HandleCacheError was designed to handle.

HandleCacheError might also get called when you have an unexpected programming error. This happens when the data has not changed but the grid can no longer find a previously loaded record. This might happen if you change constraints dynamically, but forget to refresh your grid around a valid record. If HandleCacheError is getting called during normal single user testing with data that is not being changed, you probably have a programming error that needs to be tracked down.

HandleCacheError is called during the grid's idle event. When called, the find failure has already occurred, its source is no longer in your call stack and it may have been called from a variety of places. The details of that error is not available at this point, which makes HandleCacheError of limited use for debugging. There is, however, a method called SetGridCacheError, which is called when the find failure occurs. Placing a breakpoint inside of this method can provide you with the debugging detail you need determine if you have a problem that needs to be fixed.