Skip to content

Commit a1b61ee

Browse files
committed
feat: Add better error message when trying to connect to DB
1 parent 752f366 commit a1b61ee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/context.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ export interface GraphQLContext {
66

77
export async function buildContext(connectionString: string | undefined) {
88
const db_client = new ArchiveNodeAdapter(connectionString);
9-
await db_client.checkSQLSchema();
9+
try {
10+
await db_client.checkSQLSchema();
11+
} catch (e) {
12+
throw new Error(
13+
`Could not connect to Postgres with the specified connection string. Please check that Postgres is available and that your connection string is correct and try again.\nReason: ${e}`
14+
);
15+
}
1016
return {
1117
db_client,
1218
};

0 commit comments

Comments
 (0)