Skip to content

@aws-sdk/client-lightsail throws the base exception instead of a specific exception #6606

@omid-sadeghi

Description

@omid-sadeghi

Checkboxes for prior research

Describe the bug

In lightsail-client, when GetStaticIpCommand and GetInstanceCommand don't find the resource, they throw LightsailServiceException but according to the docs for GetStaticIpCommand and GetInstanceCommand, they should throw NotFoundException and the current behaviour makes instanceof useless for checking type of the exception at runtime because LightsailServiceException is the base exception. Unfortunately, I must resort to checking by the the name property.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.9.0

Reproduction Steps

import { LightsailClient,  GetInstanceCommand,  GetStaticIpCommand, NotFoundException, LightsailServiceException} from "@aws-sdk/client-lightsail";
    
const client = new LightsailClient({});

try{
    await client.send(new GetInstanceCommand({instanceName: "non-existent instance"}));
}
catch(e){
    if(e instanceof NotFoundException)
        console.log("NotFoundException")
    else if(e instanceof LightsailServiceException)
        console.log("LightsailServiceException");
}

try{
    await client.send(new GetStaticIpCommand({staticIpName: "non-existent static ip"}));
}
catch(e){
    if(e instanceof NotFoundException)
        console.log("NotFoundException")
    else if(e instanceof LightsailServiceException)
        console.log("LightsailServiceException");
}

Observed Behavior

The code outputs:
LightsailServiceException
LightsailServiceException

Expected Behavior

I expect to see:
NotFoundException
NotFoundException

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

p2This is a standard priority issueservice-apiThis issue is due to a problem in a service API, not the SDK implementation.wontfixWe have determined that we will not resolve the issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions