Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Error object for promise rejection #181

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/switchbot-device-wocurtain.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice {

/* ------------------------------------------------------------------
* runToPos()
* - run to the targe position
* - run to the target position
*
* [Arguments]
* - percent | number | Required | the percentage of target position
Expand All @@ -63,7 +63,7 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
return new Promise((resolve, reject) => {
reject(
new Error(
"The type of target position percentage is incorrent: " +
"The type of target position percentage is incorrect: " +
typeof percent
)
);
Expand All @@ -75,7 +75,7 @@ class SwitchbotDeviceWoCurtain extends SwitchbotDevice {
if (typeof mode != "number") {
return new Promise((resolve, reject) => {
reject(
new Error("The type of running mode is incorrent: " + typeof mode)
new Error("The type of running mode is incorrect: " + typeof mode)
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/switchbot-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class SwitchbotDevice {
this._connect()
.then(() => {
if (!this._chars) {
return reject("No characteristics available.");
return reject(new Error("No characteristics available."));
}
return this._write(this._chars.write, req_buf);
})
Expand Down