---
title: Customize the Ruby SDK error handler
slug: feature-experimentation/docs/customize-error-handler-ruby
docTags: 
createdAt: 2026-08-05T20:39:51.000Z
---

You can provide your own custom **error handler** logic to standardize across your production environment.

This error handler is called when an unknown feature flag key is referenced.

See The following code example. If the error handler is not overridden, a no-op error handler is used by default.

```ruby
require 'optimizely'

# In a development environment, you might want the SDK to raise errors. In that case you can use out built-in RaiseErrorHandler
error_handler = Optimizely::RaiseErrorHandler.new

# You can also define your own error handler
class CustomErrorHandler < Optimizely::BaseErrorHandler
  def handle_error(error)
    # You can handle this error in any way you'd like
    puts error
  end
end

error_handler = CustomErrorHandler.new

# Pass the error handler into the Optimizely instance
optimizely_client = Optimizely::Project.new(
  datafile: datafile,
  error_handler: error_handler
)
```
