Skip to content

Commit

Permalink
improve setAta error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Oct 1, 2024
1 parent cc669d3 commit cdd18b6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@olivierzal/melcloud-api",
"version": "11.0.1",
"version": "11.0.2",
"description": "MELCloud API for Node.js",
"keywords": [
"melcloud",
Expand Down
3 changes: 3 additions & 0 deletions src/decorators/updateDevices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default <T extends boolean | FailureData | GroupAtaState | SuccessData>(
...args: unknown[]
) {
const [arg] = args
if (arg !== null && typeof arg === 'object' && !Object.keys(arg).length) {
throw new Error('No data to set')
}
const data = await target.call(this, arg)
const newData =
String(context.name) === 'SetPower' ?
Expand Down
3 changes: 0 additions & 3 deletions src/facades/base_super_device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export default abstract class<
public async setAta(
state: GroupAtaState,
): Promise<FailureData | SuccessData> {
if (!Object.keys(state).length) {
throw new Error('No data to set')
}
try {
return (
await this.api.setAta({
Expand Down

0 comments on commit cdd18b6

Please sign in to comment.