Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Add loggers with additional info for QBO connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 committed Dec 13, 2023
1 parent d0300ae commit dbb5da9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/app/core/services/core/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export class ApiService {
private http: HttpClient
) { }

private handleError(error: HttpErrorResponse, httpMethod: string) {
private handleError(error: HttpErrorResponse, httpMethod: string, url: string) {
if (error.error instanceof ErrorEvent) {
console.error('An error occurred:', error.error.message);
} else {
console.error(
`Backend returned code ${error.status}, method was: ${httpMethod}, body was: ${JSON.stringify(error.error)}`
`Backend returned code ${error.status}, method was: ${httpMethod}, body was: ${JSON.stringify(error.error)}, url was: ${url}`
);
}
return throwError(error);
Expand All @@ -39,14 +39,14 @@ export class ApiService {
// Having any here is ok
post(endpoint: string, body: {}): Observable<any> {
return this.http.post(API_BASE_URL + endpoint, body, httpOptions).pipe(catchError(error => {
return this.handleError(error, 'POST');
return this.handleError(error, 'POST', API_BASE_URL + endpoint);
}));
}

// Having any here is ok
put(endpoint: string, body: {}): Observable<any> {
return this.http.put(API_BASE_URL + endpoint, body, httpOptions).pipe(catchError(error => {
return this.handleError(error, 'PUT');
return this.handleError(error, 'PUT', API_BASE_URL + endpoint);
}));
}

Expand All @@ -58,21 +58,21 @@ export class ApiService {
});

return this.http.get(API_BASE_URL + endpoint, { params }).pipe(catchError(error => {
return this.handleError(error, 'GET');
return this.handleError(error, 'GET', API_BASE_URL + endpoint);
}));
}

// Having any here is ok
patch(endpoint: string, body: {}): Observable<any> {
return this.http.patch(API_BASE_URL + endpoint, body, httpOptions).pipe(catchError(error => {
return this.handleError(error, 'PATCH');
return this.handleError(error, 'PATCH', API_BASE_URL + endpoint);
}));
}

// Having any here is ok
delete(endpoint: string): Observable<any> {
return this.http.delete(API_BASE_URL + endpoint, httpOptions).pipe(catchError(error => {
return this.handleError(error, 'DELETE');
return this.handleError(error, 'DELETE', API_BASE_URL + endpoint);
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class QboConnectorComponent implements OnInit, OnDestroy {
this.showOrHideDisconnectQBO();
});
}, (error) => {
console.error('QBO Connection', JSON.stringify(error));
const errorMessage = 'message' in error.error ? error.error.message : 'Failed to connect to QuickBooks Online. Please try again';
if (errorMessage === 'Please choose the correct QuickBooks Online account') {
this.showWarningDialog();
Expand Down

0 comments on commit dbb5da9

Please sign in to comment.