Skip to content

Commit

Permalink
Improve error handling (#1182)
Browse files Browse the repository at this point in the history
* improve exception

* log input field if exists

* bump version

* fix text
  • Loading branch information
pgrivachev authored Sep 6, 2023
1 parent 3fae92e commit 92cadac
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Wizard for dbt Core (TM)",
"description": "This extension will help you work with dbt",
"icon": "images/Icon.png",
"version": "0.30.0",
"version": "0.30.1",
"publisher": "Fivetran",
"license": "MIT",
"preview": true,
Expand Down
2 changes: 1 addition & 1 deletion server/src/dbt_execution/DbtCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class DbtCli {
this.notificationSender.sendTelemetry('error', {
name: 'vscodeErrorMessage',
message: `${message}.
Profile: ${dbtProfileType ?? '_'}.
Profile: ${dbtProfileType ?? 'undefined'}.
Python: ${this.featureFinder.pythonInfo.version?.join('.') ?? '_'}.
dbt: ${JSON.stringify(this.featureFinder.versionInfo?.installedVersion)}.
Adapters: ${JSON.stringify(this.featureFinder.versionInfo?.installedAdapters)}`,
Expand Down
1 change: 1 addition & 0 deletions server/src/lsp_server/LspServerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export abstract class LspServerBase<T extends FeatureFinderBase> {
name: error.name,
message: error.message,
stack,
input: 'input' in error ? (error.input as string) : 'undefined',
});

throw new Error('Uncaught exception. Server will be restarted.');
Expand Down
6 changes: 5 additions & 1 deletion server/src/utils/JinjaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export function evalProfilesYmlJinjaEnvVar(text: string): string | object | numb
}

if (/\|\s*as_native/.test(text)) {
return JSON.parse(resultText) as object;
try {
return JSON.parse(resultText) as object;
} catch (e) {
throw new Error(`Failed to parse ${text} and ${resultText} ${e instanceof Error ? e.message : ''}}`);
}
}
if (/\|\s*(?:int|as_number)/.test(text)) {
return Number(resultText);
Expand Down

0 comments on commit 92cadac

Please sign in to comment.