Skip to content

Commit

Permalink
Check for two error types. Make sure we do not double display an error (
Browse files Browse the repository at this point in the history
#204)

* Check for two error types. Make sure we do not double display an error

* Import the new type checks

* Change name of parameter to modal with a default of false

* Update roku-deploy install
  • Loading branch information
Christian-Holbrook authored Dec 11, 2024
1 parent cc32b3c commit a114882
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 71 deletions.
68 changes: 9 additions & 59 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
"@types/request": "^2.48.8",
"@types/semver": "^7.3.9",
"@types/sinon": "^10.0.6",
"@types/yargs": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"@types/yargs": "^15.0.5",
"chai": "^4.3.4",
"coveralls-next": "^4.2.0",
"decompress": "^4.2.1",
Expand Down Expand Up @@ -113,7 +113,7 @@
"postman-request": "^2.88.1-postman.40",
"replace-in-file": "^6.3.2",
"replace-last": "^1.2.6",
"roku-deploy": "^3.12.2",
"roku-deploy": "^3.12.3",
"semver": "^7.5.4",
"serialize-error": "^8.1.0",
"smart-buffer": "^4.2.0",
Expand Down
18 changes: 8 additions & 10 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fsExtra from 'fs-extra';
import { orderBy } from 'natural-orderby';
import * as path from 'path';
import { rokuDeploy, CompileError } from 'roku-deploy';
import { rokuDeploy, CompileError, isUpdateCheckRequiredError, isConnectionResetError } from 'roku-deploy';
import type { DeviceInfo, RokuDeploy, RokuDeployOptions } from 'roku-deploy';
import {
BreakpointEvent,
Expand Down Expand Up @@ -530,8 +530,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
const statusCode = e?.results?.response?.statusCode;
const message = e.message as string;
if (statusCode === 401) {
this.showPopupMessage(message, 'error', true);
await this.shutdown(message);
await this.shutdown(message, true);
throw e;
}
this.logger.warn('Failed to delete the dev channel...probably not a big deal', e);
Expand Down Expand Up @@ -563,9 +562,8 @@ export class BrightScriptDebugSession extends BaseDebugSession {
}).catch(async (e) => {
const statusCode = e?.results?.response?.statusCode;
const message = e.message as string;
if (statusCode && statusCode !== 200) {
this.showPopupMessage(message, 'error', true);
await this.shutdown(message);
if ((statusCode && statusCode !== 200) || isUpdateCheckRequiredError(e) || isConnectionResetError(e)) {
await this.shutdown(message, true);
throw e;
}
this.logger.error(e);
Expand Down Expand Up @@ -1277,7 +1275,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
deferred.resolve();
}

private async evaluateExpressionToTempVar(args: DebugProtocol.EvaluateArguments, variablePath: string[]): Promise< { evalArgs: DebugProtocol.EvaluateArguments; variablePath: string[] } > {
private async evaluateExpressionToTempVar(args: DebugProtocol.EvaluateArguments, variablePath: string[]): Promise<{ evalArgs: DebugProtocol.EvaluateArguments; variablePath: string[] }> {
let returnVal = { evalArgs: args, variablePath };
if (!variablePath && util.isAssignableExpression(args.expression)) {
let varIndex = this.getNextVarIndex(args.frameId);
Expand Down Expand Up @@ -1545,7 +1543,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
* Called when the debugger is terminated. Feel free to call this as frequently as you want; we'll only run the shutdown process the first time, and return
* the same promise on subsequent calls
*/
public async shutdown(errorMessage?: string): Promise<void> {
public async shutdown(errorMessage?: string, modal = false): Promise<void> {
if (this.shutdownPromise === undefined) {
this.logger.log('[shutdown] Beginning shutdown sequence', errorMessage);
this.shutdownPromise = this._shutdown(errorMessage);
Expand All @@ -1555,7 +1553,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
return this.shutdownPromise;
}

private async _shutdown(errorMessage?: string): Promise<void> {
private async _shutdown(errorMessage?: string, modal = false): Promise<void> {
try {
this.componentLibraryServer?.stop();

Expand All @@ -1578,7 +1576,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
//if there was an error message, display it to the user
if (errorMessage) {
this.logger.error(errorMessage);
this.showPopupMessage(errorMessage, 'error');
this.showPopupMessage(errorMessage, 'error', modal);
}

this.logger.log('Destroy rokuAdapter');
Expand Down

0 comments on commit a114882

Please sign in to comment.