Skip to content

Commit d46e4df

Browse files
committed
Fix issue that some commands throw unintended type of exceptions on timeout.
1 parent 8ab437c commit d46e4df

7 files changed

Lines changed: 11 additions & 11 deletions

File tree

Public/Batch/Wait-Batch.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function Wait-Batch {
123123
} while ($innerBatchObject.status -and $innerBatchObject.status -in $innerStatusForWait)
124124
}
125125
catch [OperationCanceledException] {
126-
Write-Error -ErrorRecord $_
126+
Write-TimeoutError
127127
return
128128
}
129129
catch {

Public/Runs/Wait-ThreadRun.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function Wait-ThreadRun {
138138
} while ($innerRunObject.status -and $innerRunObject.status -in $innerStatusForWait)
139139
}
140140
catch [OperationCanceledException] {
141-
Write-Error -ErrorRecord $_
141+
Write-TimeoutError
142142
return
143143
}
144144
catch {

Public/VectorStores/Batches/Wait-VectorStoreFileBatch.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function Wait-VectorStoreFileBatch {
134134
} while ($innerBatchObject.status -and $innerBatchObject.status -in $innerStatusForWait)
135135
}
136136
catch [OperationCanceledException] {
137-
Write-Error -ErrorRecord $_
137+
Write-TimeoutError
138138
return
139139
}
140140
catch {

Tests/Batch/Wait-Batch.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Describe 'Wait-Batch' {
6969
id = 'batch_abc123'
7070
status = 'in_progress'
7171
}
72-
{ $script:Result = Wait-Batch -InputObject $InObject -StatusForWait ('cancelling', 'failed') -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([System.OperationCanceledException])
72+
{ $script:Result = Wait-Batch -InputObject $InObject -StatusForWait ('cancelling', 'failed') -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
7373
Should -Invoke Get-Batch -ModuleName $script:ModuleName -Times 1
7474
}
7575

@@ -104,7 +104,7 @@ Describe 'Wait-Batch' {
104104
id = 'batch_abc123'
105105
status = 'in_progress'
106106
}
107-
{ $script:Result = Wait-Batch -InputObject $InObject -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([OperationCanceledException])
107+
{ $script:Result = Wait-Batch -InputObject $InObject -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
108108
Should -Invoke Get-Batch -ModuleName $script:ModuleName -Times 3
109109
$Result | Should -BeNullOrEmpty
110110
}
@@ -123,7 +123,7 @@ Describe 'Wait-Batch' {
123123
id = 'batch_abc123'
124124
status = 'in_progress'
125125
}
126-
{ $script:Result = Wait-Batch -InputObject $InObject -TimeoutSec 2 -PollIntervalSec 100 -ea Stop } | Should -Throw -ExceptionType ([OperationCanceledException])
126+
{ $script:Result = Wait-Batch -InputObject $InObject -TimeoutSec 2 -PollIntervalSec 100 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
127127
Should -Invoke Get-Batch -ModuleName $script:ModuleName -Times 1 -Exactly
128128
$Result | Should -BeNullOrEmpty
129129
}

Tests/Runs/Wait-ThreadRun.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Describe 'Wait-ThreadRun' {
119119
thread_id = 'thread_abc123'
120120
status = 'in_progress'
121121
}
122-
{ $script:Result = Wait-ThreadRun -InputObject $InObject -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([OperationCanceledException])
122+
{ $script:Result = Wait-ThreadRun -InputObject $InObject -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
123123
Should -Invoke Get-ThreadRun -ModuleName $script:ModuleName -Times 3
124124
$Result | Should -BeNullOrEmpty
125125
}
@@ -141,7 +141,7 @@ Describe 'Wait-ThreadRun' {
141141
thread_id = 'thread_abc123'
142142
status = 'in_progress'
143143
}
144-
{ $script:Result = Wait-ThreadRun -InputObject $InObject -TimeoutSec 2 -PollIntervalSec 100 -ea Stop } | Should -Throw -ExceptionType ([OperationCanceledException])
144+
{ $script:Result = Wait-ThreadRun -InputObject $InObject -TimeoutSec 2 -PollIntervalSec 100 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
145145
Should -Invoke Get-ThreadRun -ModuleName $script:ModuleName -Times 1
146146
$Result | Should -BeNullOrEmpty
147147
}

Tests/Threads/Add-ThreadMessage.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Describe 'Add-ThreadMessage' {
153153
ErrorAction = 'Stop'
154154
}
155155
$script:Result = Add-ThreadMessage @splat
156-
} | Should -Throw -ExceptionType ([OperationCanceledException])
156+
} | Should -Throw -ExceptionType ([System.TimeoutException])
157157
Should -Not -Invoke Invoke-OpenAIAPIRequest -ModuleName $script:ModuleName
158158
Should -Invoke Get-ThreadRun -ModuleName $script:ModuleName -Times 1
159159
$script:Result | Should -BeNullOrEmpty

Tests/VectorStores/Wait-VectorStoreFileBatch.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Describe 'Wait-VectorStoreFileBatch' {
115115
vector_store_id = 'vs_abc123'
116116
status = 'in_progress'
117117
}
118-
{ $script:Result = Wait-VectorStoreFileBatch -Batch $InObject -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([OperationCanceledException])
118+
{ $script:Result = Wait-VectorStoreFileBatch -Batch $InObject -TimeoutSec 2 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
119119
Should -Invoke Get-VectorStoreFileBatch -ModuleName $script:ModuleName -Times 3
120120
$Result | Should -BeNullOrEmpty
121121
}
@@ -136,7 +136,7 @@ Describe 'Wait-VectorStoreFileBatch' {
136136
vector_store_id = 'vs_abc123'
137137
status = 'in_progress'
138138
}
139-
{ $script:Result = Wait-VectorStoreFileBatch -Batch $InObject -TimeoutSec 2 -PollIntervalSec 100 -ea Stop } | Should -Throw -ExceptionType ([OperationCanceledException])
139+
{ $script:Result = Wait-VectorStoreFileBatch -Batch $InObject -TimeoutSec 2 -PollIntervalSec 100 -ea Stop } | Should -Throw -ExceptionType ([System.TimeoutException])
140140
Should -Invoke Get-VectorStoreFileBatch -ModuleName $script:ModuleName -Times 1 -Exactly
141141
}
142142

0 commit comments

Comments
 (0)