函数fetch_details在线程内调用。它有一个发布请求,在失败的情况下会引发CustomError。我需要测试 CustomError而不实际发出实际的发布请求。
Thread.new {
begin
details = fetch_details(a, b)
param1, param2 = parse_details(details, b)
post_result("Success", url)
rescue CustomError => e
post_result(e.message, url)
end
}
我如何在fetch_details函数中添加发帖请求以引发自定义错误?