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

added custom error #76

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/helpers/api.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ApiHelper {
return response;
} catch (error: any) {
this.logger.logError("Error in ApiHelper->get");
throw error;
throw new Error(`Error in get request ${error.message}`);
}
}
}
20 changes: 12 additions & 8 deletions src/helpers/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export class ApiClient {
return config as InternalAxiosRequestConfig;
},
(error) => {
this.errorHandler.handleError(error);
return Promise.reject(error);
const errorObj = new Error(`Error in interceptors request: ${error.message}`);
this.errorHandler.handleError(errorObj);
return Promise.reject(errorObj);
},
);

Expand All @@ -43,8 +44,9 @@ export class ApiClient {
return response;
},
(error) => {
this.errorHandler.handleError(error);
return Promise.reject(error);
const errorObj = new Error(`Error in interceptors response: ${error.message}`);
this.errorHandler.handleError(errorObj);
return Promise.reject(errorObj);
},
);
}
Expand All @@ -62,10 +64,11 @@ export class ApiClient {
span.end(new Date());
return response.data;
} catch (error: any) {
const errorObj = new Error(`Error in get request: ${error.message}`);
span.setStatus(error.code);
span.end(new Date());
Sentry.captureException(error);
throw error;
Sentry.captureException(errorObj);
throw errorObj;
}
},
);
Expand All @@ -84,10 +87,11 @@ export class ApiClient {
span.end(new Date());
return response.data;
} catch (error: any) {
const errorObj = new Error(`Error in post request: ${error.message}`);
span.setStatus(error.code);
span.end(new Date());
Sentry.captureException(error);
throw error;
Sentry.captureException(errorObj);
throw errorObj;
}
},
);
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/command.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ export class Command {
if (accessToken) {
this.logger.logMessageByStatus(
MessageStatus.INFO,
`${Messages.CMD_EXEC_WITH_ACCESS_TOKEN}: "${command} "`,
`${Messages.CMD_EXEC_WITH_ACCESS_TOKEN}`,
);
command = `${command} ${globalFlags[0].flag} ${accessToken}`;
}
} else {
this.logger.logMessageByStatus(
MessageStatus.INFO,
`${Messages.CMD_EXEC_WITHOUT_ACCESS_TOKEN}: "${command}"`,
`${Messages.CMD_EXEC_WITHOUT_ACCESS_TOKEN}"`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ErrorHandler {

this.logError(errorMessage, errorStack);
this.showUserErrorMessage(customErrorMessage ?? errorMessage);
this.sentryHelper.captureException(new Error(`Error Found :`, error));
this.sentryHelper.captureException(new Error(`Error Found :`, error.message));
}

private extractErrorMessage(error: unknown): string {
Expand Down
2 changes: 1 addition & 1 deletion src/services/scan.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class ScanService {
case "-j":
if (selectedFlags.report) {
cmdParams.push(selectedFlags.report);
Logger.logMessageByStatus(MessageStatus.INFO, `Report added: ${selectedFlags.report}`);
Logger.logMessageByStatus(MessageStatus.INFO, `Report added`);
}
break;

Expand Down
Loading