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

Identify when a 577 error is thrown, send a new developer friendly message #180

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ export class MissingRequiredOptionError extends Error {
Object.setPrototypeOf(this, MissingRequiredOptionError.prototype);
}
}

export class UpdateCheckRequiredError extends Error {
results: any;

cause: Error;

constructor(originalError: Error) {
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.\n\nhttps://support.roku.com/article/208755668.`;
this.results = { response: { statusCode: 577 } };
this.cause = originalError;
Object.setPrototypeOf(this, UpdateCheckRequiredError.prototype);
}
}
13 changes: 13 additions & 0 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,19 @@ describe('index', () => {
});
});

it('rejects when response contains invalid password status code', () => {
options.failOnCompileError = true;
mockDoPostRequest('', 577);

return rokuDeploy.publish(options).then(() => {
assert.fail('Should not have succeeded due to roku server compilation failure');
}, (err) => {
expect(err.message).to.be.a('string').and.satisfy(msg => msg.startsWith(`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.`));
});
});

it('handles successful deploy', () => {
options.failOnCompileError = true;
mockDoPostRequest();
Expand Down
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.UpdateCheckRequiredError(installError);
default:
throw installError;
}
}
}
}

Expand Down