Stay organized with collections
Save and categorize content based on your preferences.
publicinterfaceErrorHandler
Handles errors raised by the MemcacheService, registered with
MemcacheService#setErrorHandler(ErrorHandler).
The default error handler is an instance of
LogAndContinueErrorHandler. In most cases, this will log
exceptions without throwing, which looks like a cache-miss behavior to
the caller. A less permissive alternative is StrictErrorHandler,
which will throw a MemcacheServiceException to surface errors
to callers.
Handles deserialization errors. This method is called from either of the
get methods, if the retrieved value
cannot be deserialized. This normally indicates an application upgrade
since the cache entry was stored, and should thus be treated as a cache
miss, which is the behavior of LogAndContinueErrorHandler (the
default).
Handles back-end service errors. This method is called from most of the
MemcacheService methods in the event of a service error. This is
also called for MemcacheService#put(Object, Object) when the
combined key and value size is too large.
The handler may throw any RuntimeException, or it may simply
return for "permissive" error handling, which will generally emulate
behavior of a cache miss due to a discarded entry.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eErrorHandler\u003c/code\u003e is an interface that manages errors raised by \u003ccode\u003eMemcacheService\u003c/code\u003e, and you can register custom error handling logic.\u003c/p\u003e\n"],["\u003cp\u003eThe default error handling behavior is defined by \u003ccode\u003eLogAndContinueErrorHandler\u003c/code\u003e, which typically logs exceptions without throwing them, resembling a cache miss.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eStrictErrorHandler\u003c/code\u003e is an alternative that will surface errors to callers by throwing a \u003ccode\u003eMemcacheServiceException\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eConsistentErrorHandler\u003c/code\u003e ensures that all \u003ccode\u003eMemcacheServiceException\u003c/code\u003e are directed to the error handler, with options like \u003ccode\u003eErrorHandlers#getConsistentLogAndContinue\u003c/code\u003e and \u003ccode\u003eErrorHandlers#getStrict\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe interface provides two methods, \u003ccode\u003ehandleDeserializationError\u003c/code\u003e which handles errors during deserialization of values and \u003ccode\u003ehandleServiceError\u003c/code\u003e which handles errors from the backend service.\u003c/p\u003e\n"]]],[],null,["# Interface ErrorHandler (2.0.0)\n\n public interface ErrorHandler\n\nHandles errors raised by the `MemcacheService`, registered with\nMemcacheService#setErrorHandler(ErrorHandler).\n\nThe default error handler is an instance of\n[LogAndContinueErrorHandler](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.LogAndContinueErrorHandler). In most cases, this will log\nexceptions without throwing, which looks like a cache-miss behavior to\nthe caller. A less permissive alternative is [StrictErrorHandler](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.StrictErrorHandler),\nwhich will throw a [MemcacheServiceException](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.MemcacheServiceException) to surface errors\nto callers.\n\nTo guarantee that all instances of [MemcacheServiceException](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.MemcacheServiceException)\nare directed to the error handler, use a [ConsistentErrorHandler](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.ConsistentErrorHandler)\nsuch as [ErrorHandlers#getConsistentLogAndContinue(Level)](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.ErrorHandlers#com_google_appengine_api_memcache_ErrorHandlers_getConsistentLogAndContinue_java_util_logging_Level_) or\n[ErrorHandlers#getStrict()](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.ErrorHandlers#com_google_appengine_api_memcache_ErrorHandlers_getStrict__).\n\nMethods\n-------\n\n### handleDeserializationError(InvalidValueException ivx)\n\n public abstract void handleDeserializationError(InvalidValueException ivx)\n\nHandles deserialization errors. This method is called from either of the\n[get](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.MemcacheService#com_google_appengine_api_memcache_MemcacheService_get_java_lang_Object_) methods, if the retrieved value\ncannot be deserialized. This normally indicates an application upgrade\nsince the cache entry was stored, and should thus be treated as a cache\nmiss, which is the behavior of [LogAndContinueErrorHandler](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.LogAndContinueErrorHandler) (the\ndefault).\n\n### handleServiceError(MemcacheServiceException ex)\n\n public abstract void handleServiceError(MemcacheServiceException ex)\n\nHandles back-end service errors. This method is called from most of the\n`MemcacheService` methods in the event of a service error. This is\nalso called for [MemcacheService#put(Object, Object)](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.MemcacheService#com_google_appengine_api_memcache_MemcacheService_put_java_lang_Object_java_lang_Object_) when the\ncombined key and value size is too large.\n\nThe handler may throw any [RuntimeException](https://docs.oracle.com/javase/8/docs/api/java/lang/RuntimeException.html), or it may simply\nreturn for \"permissive\" error handling, which will generally emulate\nbehavior of a cache miss due to a discarded entry."]]