自定义错误处理程序
2023年5月11日小于 1 分钟
自定义错误处理程序
如何为云眼灰度标帜(Feature Flag)AB实验 C# SDK 创建自己的错误处理程序逻辑。
可以提供自己的自定义错误处理程序逻辑,以标准化整个生产环境中的错误消息。
当 C# SDK 未按预期执行时,将调用此错误处理程序。这可能是由于向 SDK 提供的参数不正确或在发生网络或任何其他中断的环境中运行 SDK 导致的。
请参阅 C# 代码示例。如果未重写错误处理程序,则默认使用无操作错误处理程序。
C#
using System; 
using EyeofcloudSDK.ErrorHandler;  
/**  
* Creates a CustomErrorHandler and calls HandleError when the SDK raises an exception.   
*  
* CustomErrorHandler should be inherited by IErrorHandler, namespace of EyeofcloudSDK.ErrorHandler.  
**/ 
public class CustomErrorHandler : IErrorHandler 
{     
    /// <summary>     
    /// Handle exceptions when raised by the SDK.     
    /// </summary>     
    /// <param name="exception">object of Exception raised by the SDK.</param>     
    public void HandleError(Exception exception)     
    {         
        throw new NotImplementedException();     
    } 
}