Skip to content

Commit

Permalink
Identify when a 577 error is thrown, send a new developer friendly me…
Browse files Browse the repository at this point in the history
…ssage
  • Loading branch information
Christian-Holbrook committed Nov 20, 2024
1 parent bfe0f5b commit 476df49
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ export class MissingRequiredOptionError extends Error {
Object.setPrototypeOf(this, MissingRequiredOptionError.prototype);
}
}

export class DeviceFailedConnectionError extends Error {
results: any;

constructor() {
super();
this.message = `Your device needs to check for updates before accepting connections. Please navigate to System Settings and check for updates and then try again.
https://support.roku.com/article/208755668.`;
this.results = { response: { statusCode: 577 } };
Object.setPrototypeOf(this, DeviceFailedConnectionError.prototype);
}
}
12 changes: 10 additions & 2 deletions src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,16 @@ export class RokuDeploy {
if (this.isCompileError(replaceError.message) && options.failOnCompileError) {
throw new errors.CompileError('Compile error', replaceError, replaceError.results);
} else {
requestOptions.formData.mysubmit = 'Install';
response = await this.doPostRequest(requestOptions);
try {
response = await this.doPostRequest(requestOptions);
} catch (installError: any) {
switch (installError.results.response.statusCode) {
case 577:
throw new errors.DeviceFailedConnectionError();
default:
throw installError;
}
}
}
}

Expand Down

0 comments on commit 476df49

Please sign in to comment.