Skip to content

Commit f4d6990

Browse files
Move duplicated error handling into showResolvableLocation
1 parent daf389a commit f4d6990

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-view.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,7 @@ export class DataExtensionsEditorView extends AbstractWebview<
230230
protected async jumpToUsage(
231231
location: ResolvableLocationValue,
232232
): Promise<void> {
233-
try {
234-
await showResolvableLocation(location, this.databaseItem);
235-
} catch (e) {
236-
if (e instanceof Error) {
237-
if (e.message.match(/File not found/)) {
238-
void window.showErrorMessage(
239-
"Original file of this result is not in the database's source archive.",
240-
);
241-
} else {
242-
void this.app.logger.log(`Unable to handleMsgFromView: ${e.message}`);
243-
}
244-
} else {
245-
void this.app.logger.log(`Unable to handleMsgFromView: ${e}`);
246-
}
247-
}
233+
await showResolvableLocation(location, this.databaseItem, this.app.logger);
248234
}
249235

250236
protected async loadExistingModeledMethods(): Promise<void> {

extensions/ql-vscode/src/databases/local-databases/locations.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,19 @@ export function tryResolveLocation(
9797
export async function showResolvableLocation(
9898
loc: ResolvableLocationValue,
9999
databaseItem: DatabaseItem,
100+
logger: Logger,
100101
): Promise<void> {
101-
await showLocation(tryResolveLocation(loc, databaseItem));
102+
try {
103+
await showLocation(tryResolveLocation(loc, databaseItem));
104+
} catch (e) {
105+
if (e instanceof Error && e.message.match(/File not found/)) {
106+
void Window.showErrorMessage(
107+
"Original file of this result is not in the database's source archive.",
108+
);
109+
} else {
110+
void logger.log(`Unable to jump to location: ${getErrorMessage(e)}`);
111+
}
112+
}
102113
}
103114

104115
export async function showLocation(location?: Location) {
@@ -146,16 +157,6 @@ export async function jumpToLocation(
146157
) {
147158
const databaseItem = databaseManager.findDatabaseItem(Uri.parse(databaseUri));
148159
if (databaseItem !== undefined) {
149-
try {
150-
await showResolvableLocation(loc, databaseItem);
151-
} catch (e) {
152-
if (e instanceof Error && e.message.match(/File not found/)) {
153-
void Window.showErrorMessage(
154-
"Original file of this result is not in the database's source archive.",
155-
);
156-
} else {
157-
void logger.log(`Unable to jump to location: ${getErrorMessage(e)}`);
158-
}
159-
}
160+
await showResolvableLocation(loc, databaseItem, logger);
160161
}
161162
}

0 commit comments

Comments
 (0)