Created
December 30, 2010 20:59
-
-
Save nz/760294 to your computer and use it in GitHub Desktop.
Silently fail instead of raising an exception when an error occurs while writing to Solr.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# | |
# Custom write failure handling when there is an error writing to Solr. | |
# Install this in an initializer. | |
# Prints error messages to stderr. | |
# | |
# NOTE: does not fail for reads; you should catch those exceptions in your controller. | |
# | |
## | |
Sunspot.session = Sunspot::SessionProxy::SilentFailSessionProxy.new(Sunspot.session) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# | |
# Silently fail instead of raising an exception when an error occurs while writing to Solr. | |
# Install this in an initializer. | |
# | |
# NOTE: does not fail for reads; you should catch those exceptions in your controller. | |
# | |
## | |
class CustomSilentFailSessionProxy < Sunspot::SessionProxy::SilentFailSessionProxy | |
def rescued_exception(method_name, e) | |
# handle the exception, e, however you like! | |
end | |
end | |
Sunspot.session = CustomSilentFailSessionProxy.new(Sunspot.session) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment