@felixgeelhaar/govee-api-client
Version:
Enterprise-grade TypeScript client library for the Govee Developer REST API
22 lines • 886 B
JavaScript
import { GoveeApiClientError } from './GoveeApiClientError';
export class InvalidApiKeyError extends GoveeApiClientError {
constructor(message = 'Invalid API key provided', cause) {
super(message, cause);
this.code = 'INVALID_API_KEY';
}
static fromUnauthorizedResponse(responseBody) {
const apiMessage = responseBody?.message;
const message = apiMessage ? `Invalid API key: ${apiMessage}` : 'Invalid API key provided';
return new InvalidApiKeyError(message);
}
getRecommendation() {
return 'Please check your API key and ensure it is valid and has not expired. You can obtain a new API key from the Govee Developer Portal.';
}
toObject() {
return {
...super.toObject(),
recommendation: this.getRecommendation(),
};
}
}
//# sourceMappingURL=InvalidApiKeyError.js.map