chore: update create connection handler

This commit is contained in:
steven
2023-03-28 14:05:56 +08:00
parent 82ecdf750b
commit 2fb70e11ff

View File

@ -50,10 +50,11 @@ const CreateConnectionModal = (props: Props) => {
if (!showDatabaseField) { if (!showDatabaseField) {
connectionCreate.database = undefined; connectionCreate.database = undefined;
} }
try {
const result = await testConnection(connectionCreate); const result = await testConnection(connectionCreate);
setIsRequesting(false);
if (!result) { if (!result) {
toast.error("Failed to connect"); setIsRequesting(false);
toast.error("Failed to test connection");
return; return;
} }
const createdConnection = connectionStore.createConnection(connectionCreate); const createdConnection = connectionStore.createConnection(connectionCreate);
@ -63,6 +64,14 @@ const CreateConnectionModal = (props: Props) => {
connection: createdConnection, connection: createdConnection,
database: head(databaseList), database: head(databaseList),
}); });
} catch (error) {
console.error(error);
setIsRequesting(false);
toast.error("Failed to create connection");
return;
}
setIsRequesting(false);
close(); close();
}; };