fix: improve NoSuchKey error handling in S3 mock
This commit is contained in:
parent
af7a1e1cbc
commit
c474f3692a
1 changed files with 4 additions and 2 deletions
|
|
@ -240,8 +240,10 @@ function handleGetObject(command: any) {
|
||||||
|
|
||||||
if (!bucket.objects.has(Key)) {
|
if (!bucket.objects.has(Key)) {
|
||||||
console.log(`Object ${Key} not found in bucket ${Bucket}`)
|
console.log(`Object ${Key} not found in bucket ${Bucket}`)
|
||||||
// Return null for non-existent objects instead of rejecting
|
// Create proper NoSuchKey error that matches AWS SDK structure
|
||||||
return Promise.reject(new Error(`NoSuchKey: The specified key does not exist.`))
|
const error = new Error(`NoSuchKey: The specified key does not exist.`)
|
||||||
|
error.name = 'NoSuchKey'
|
||||||
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const object = bucket.objects.get(Key)!
|
const object = bucket.objects.get(Key)!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue