自定义错误处理程序

云眼Less than 1 minute

自定义错误处理程序

本主题介绍如何为云眼灰度发布(特性标帜)AB实验 Ruby SDK 创建自己的错误处理程序逻辑。

可以提供自己的自定义错误处理程序逻辑,以在整个生产环境中实现标准化。

引用未知灰度发布(特性标帜)键时,将调用此错误处理程序。

请参阅下面的代码示例。如果未重写错误处理程序,则默认使用无操作错误处理程序。

Rubby

# In a development environment, you might want the SDK to raise errors. In that case you can use out built-in RaiseErrorHandler error_handler = Eyeofcloud::RaiseErrorHandler.new # You can also define your own error handler class CustomErrorHandler < Eyeofcloud::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 Eyeofcloud instance eyeofcloud_client = Eyeofcloud::Project.new(datafile, Eyeofcloud::EventDispatcher.new, Eyeofcloud::NoOpLogger.new, error_handler )

Last update:
Contributors: “zhangweixue”,zhangweixue