in packages/graph-explorer/src/modules/GraphViewer/ImportGraphButton.tsx [127:169]
export function createErrorNotification(
error: Error,
file: File,
allConnections: ConnectionWithId[]
): Notification {
if (error instanceof ZodError) {
// Parsing has failed
logger.error(`Failed to parse the file "${file.name}"`, error.format());
return {
message: `Parsing the file "${file.name}" failed. Please ensure the file was originally saved from Graph Explorer and is not corrupt.`,
type: "error",
};
} else if (error instanceof InvalidConnectionError) {
// Invalid connection
const matchingByUrlAndQueryEngine = allConnections.filter(connection =>
isMatchingConnection(connection, error.connection)
);
// Get the display label for the given query engine
const displayQueryEngine = getTranslation(
"available-connections.graph-type",
error.connection.queryEngine
);
if (matchingByUrlAndQueryEngine.length > 0) {
const matchingConnection = matchingByUrlAndQueryEngine[0];
return {
message: `The graph file requires switching to connection ${matchingConnection.displayLabel}.`,
type: "error",
};
} else {
const dbUrl = error.connection.dbUrl;
return {
message: `The graph file requires a connection to ${dbUrl} using the graph type ${displayQueryEngine}.`,
type: "error",
};
}
}
return {
message: `Failed to load the graph because an error occurred.`,
type: "error",
};
}