Move duplicated error handling into showResolvableLocation
This commit is contained in:
@@ -230,21 +230,7 @@ export class DataExtensionsEditorView extends AbstractWebview<
|
||||
protected async jumpToUsage(
|
||||
location: ResolvableLocationValue,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await showResolvableLocation(location, this.databaseItem);
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
if (e.message.match(/File not found/)) {
|
||||
void window.showErrorMessage(
|
||||
"Original file of this result is not in the database's source archive.",
|
||||
);
|
||||
} else {
|
||||
void this.app.logger.log(`Unable to handleMsgFromView: ${e.message}`);
|
||||
}
|
||||
} else {
|
||||
void this.app.logger.log(`Unable to handleMsgFromView: ${e}`);
|
||||
}
|
||||
}
|
||||
await showResolvableLocation(location, this.databaseItem, this.app.logger);
|
||||
}
|
||||
|
||||
protected async loadExistingModeledMethods(): Promise<void> {
|
||||
|
||||
@@ -97,8 +97,19 @@ export function tryResolveLocation(
|
||||
export async function showResolvableLocation(
|
||||
loc: ResolvableLocationValue,
|
||||
databaseItem: DatabaseItem,
|
||||
logger: Logger,
|
||||
): Promise<void> {
|
||||
await showLocation(tryResolveLocation(loc, databaseItem));
|
||||
try {
|
||||
await showLocation(tryResolveLocation(loc, databaseItem));
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message.match(/File not found/)) {
|
||||
void Window.showErrorMessage(
|
||||
"Original file of this result is not in the database's source archive.",
|
||||
);
|
||||
} else {
|
||||
void logger.log(`Unable to jump to location: ${getErrorMessage(e)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function showLocation(location?: Location) {
|
||||
@@ -146,16 +157,6 @@ export async function jumpToLocation(
|
||||
) {
|
||||
const databaseItem = databaseManager.findDatabaseItem(Uri.parse(databaseUri));
|
||||
if (databaseItem !== undefined) {
|
||||
try {
|
||||
await showResolvableLocation(loc, databaseItem);
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message.match(/File not found/)) {
|
||||
void Window.showErrorMessage(
|
||||
"Original file of this result is not in the database's source archive.",
|
||||
);
|
||||
} else {
|
||||
void logger.log(`Unable to jump to location: ${getErrorMessage(e)}`);
|
||||
}
|
||||
}
|
||||
await showResolvableLocation(loc, databaseItem, logger);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user