0

我正在尝试创建一个虚假的 webrequest 响应来抛出一个 catch 块。这与我的床上表演相去甚远,我不知道我在做什么。有没有人可以帮助我,或者给我看一个文档/博客来解释这样的事情?

下面是我所拥有的。我知道我现在根本没有在 $fakewebrequest 中使用 $webresponse ...

$Response = [PSCustomObject]@{
    StatusCode = 429
}
$webresponse = [PSCustomObject]@{
    Exception = [PSCustomObject]@{
        response = [PSCustomObject]@{
            headers = [PSCustomObject]@{
                'retry-after' =  ( 5, 10, 15 | Get-random)
            }
        }
    }
}
$FakeWebRequest = [System.Net.WebException]::new('This is just a test',([System.Exception]::new('test?')),([System.Net.WebExceptionStatus]::Pending),[system.net.httpwebresponse]::new())
4

0 回答 0