Skip to content

Commit

Permalink
Fix:(webapp) PR review updates. Remove string parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristahouse committed Mar 5, 2024
1 parent 86da9dc commit 0a34ec9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ export class WebClientArdComponent extends WebClientBaseComponent implements On
}

private getMessage(errorData: UserIronRdpError | string): string {
const errorKind: UserIronRdpErrorKind = this.getErrorKind(errorData);
let errorKind: UserIronRdpErrorKind = UserIronRdpErrorKind.General;

if (typeof errorData === 'string') {
console.error(errorData);
} else {
errorKind = errorData.kind();
}

//For translation 'UnknownError'
//For translation 'ConnectionErrorPleaseVerifyYourConnectionSettings'
Expand All @@ -398,32 +404,4 @@ export class WebClientArdComponent extends WebClientBaseComponent implements On
return 'Connection error: Please verify your connection settings.';
}
}

private getErrorKind(errorData: UserIronRdpError | string): UserIronRdpErrorKind {
if (typeof errorData === 'string') {
return this.parseErrorString(errorData);
}

if (errorData?.kind() !== UserIronRdpErrorKind.General) {
return errorData.kind();
}

console.error('Error Kind:', errorData.kind());
const backtrace: string = errorData?.backtrace();
return this.parseErrorString(backtrace);
}

private parseErrorString(error: string): UserIronRdpErrorKind {
console.error(error);

if (error.indexOf('authentication rejected') >= 0) {
return UserIronRdpErrorKind.WrongPassword;
}

if (error.indexOf('connection has been rejected') >= 0) {
return UserIronRdpErrorKind.LogonFailure;
}

return UserIronRdpErrorKind.General;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ export class WebClientVncComponent extends WebClientBaseComponent implements On
}

private getMessage(errorData: UserIronRdpError | string): string {
const errorKind: UserIronRdpErrorKind = this.getErrorKind(errorData);
let errorKind: UserIronRdpErrorKind = UserIronRdpErrorKind.General;

if (typeof errorData === 'string') {
console.error(errorData);
} else {
errorKind = errorData.kind();
}

//For translation 'UnknownError'
//For translation 'ConnectionErrorPleaseVerifyYourConnectionSettings'
Expand All @@ -398,32 +404,4 @@ export class WebClientVncComponent extends WebClientBaseComponent implements On
return 'Connection error: Please verify your connection settings.';
}
}

private getErrorKind(errorData: UserIronRdpError | string): UserIronRdpErrorKind {
if (typeof errorData === 'string') {
return this.parseErrorString(errorData);
}

if (errorData?.kind() !== UserIronRdpErrorKind.General) {
return errorData.kind();
}

console.error('Error Kind:', errorData.kind());
const backtrace: string = errorData?.backtrace();
return this.parseErrorString(backtrace);
}

private parseErrorString(error: string): UserIronRdpErrorKind {
console.error(error);

if (error.indexOf('authentication rejected') >= 0) {
return UserIronRdpErrorKind.WrongPassword;
}

if (error.indexOf('connection has been rejected') >= 0) {
return UserIronRdpErrorKind.LogonFailure;
}

return UserIronRdpErrorKind.General;
}
}

0 comments on commit 0a34ec9

Please sign in to comment.