Skip to content
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@
"ignore": "^5.1.4",
"mz": "^2.7.0",
"open": "^7.0.0",
"@deepcode/tsc": "^1.1.0"
"@deepcode/tsc": "^1.2.0"
}
}
11 changes: 6 additions & 5 deletions src/deepcode/http/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IDE_NAME } from "../constants/general";
const AI = new ServiceAI();

const http = {

login(baseURL: string, source: string = IDE_NAME): Promise<any> {
return AI.startSession({ baseURL, source });
},
Expand All @@ -35,10 +35,11 @@ const http = {
});
},

// TODO: when API package will implement such functionality
// we would have the possibility to send an error to server
async sendError(body: any): Promise<void> {
return Promise.resolve();
async sendError(baseURL: string, options: object): Promise<any> {
return AI.reportError({
baseURL,
...options
});
}
};

Expand Down
30 changes: 17 additions & 13 deletions src/deepcode/lib/errorHandler/DeepCodeErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DeepCodeErrorHandler implements DeepCode.ErrorHandlerInterface {
private async serverErrorHandler(extension: DeepCode.ExtensionInterface | any): Promise<void> {
const { msg } = deepCodeMessages.noConnection;
vscode.window.showErrorMessage(msg);

setTimeout(async () => {
startDeepCodeCommand();
}, 5000);
Expand Down Expand Up @@ -86,19 +86,23 @@ class DeepCodeErrorHandler implements DeepCode.ErrorHandlerInterface {
error: DeepCode.errorType,
options: { [key: string]: any }
): Promise<void> {
if (process.env.NODE_ENV === "production") {
if (process.env.NODE_ENV === "production" || extension.baseURL !== extension.defaultBaseURL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe !== should be === ?

// please disable request sending in dev mode to avoid unnecessary reports to server
await http.sendError({
//for testing edpoint use source: 'test'
source: IDE_NAME,
type: `${error.statusCode || ""} ${error.name || ""}`.trim(),
errorTrace: JSON.stringify(error),
message: options.message || errorsLogs.undefinedError,
...(extension.token && { sessionToken: extension.token }),
...(options.endpoint && { path: options.endpoint }),
...(options.bundleId && { bundleId: options.bundleId }),
...(options.data && { data: options.data })
});
await http.sendError(
extension.baseURL,
{
source: extension.source,
type: `${error.statusCode || ""} ${error.name || ""}`.trim(),
message: options.message || errorsLogs.undefinedError,
...(extension.token && { sessionToken: extension.token }),
...(options.endpoint && { path: options.endpoint }),
...(options.bundleId && { bundleId: options.bundleId }),
data: {
errorTrace: JSON.stringify(error),
...options.data
}
}
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/DeepCodeInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace DeepCode {
extension: ExtensionInterface | any,
error: errorType,
options?: { [key: string]: any }
): void;
): Promise<void>;
}

export interface BaseDeepCodeModuleInterface {
Expand Down