Skip to content
Closed
Changes from 1 commit
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
Next Next commit
fix: TT-283 added try catch to handle method rerenderDataTable
  • Loading branch information
kevinjlope committed Jul 6, 2021
commit 89b3e6404288088c18ce3c33c70710c7a9415a6d
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { formatDate } from '@angular/common';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import { select, Store } from '@ngrx/store';
import { DataTableDirective } from 'angular-datatables';
import * as console from 'console';
import * as moment from 'moment';
import { Observable, Subject } from 'rxjs';
import { Entry } from 'src/app/modules/shared/models';
Expand Down Expand Up @@ -82,11 +83,15 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
private rerenderDataTable(): void {
if (this.dtElement && this.dtElement.dtInstance) {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not a correct way to implement a try catch, you can use the if / else or else try / catch but not the two together.

I am attaching a link with information on the correct use of a try / catch.
https://javascript.plainenglish.io/the-dark-side-of-typescript-try-catch-deeded18ba0d

dtInstance.destroy();
this.dtTrigger.next();
try {
dtInstance.destroy();
this.dtTrigger.next();
} catch (error) {}
});
} else {
this.dtTrigger.next();
try {
this.dtTrigger.next();
} catch (error) {}
}
}

Expand Down