Skip to content

Commit

Permalink
chore(data-warehouse): add error handling to postgres modal form (#20159
Browse files Browse the repository at this point in the history
)

add error handling to postgres modal form
  • Loading branch information
EDsCODE authored Feb 6, 2024
1 parent 9a38a3d commit 0d55f92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export const sourceFormLogic = kea<sourceFormLogicType>([
submitExternalDataSourceFailure: ({ error }) => {
lemonToast.error(error?.message || 'Something went wrong')
},
submitDatabaseSchemaFormFailure: ({ error }) => {
lemonToast.error(error?.message || 'Something went wrong')
},
handleRedirect: async ({ kind, searchParams }) => {
switch (kind) {
case 'hubspot': {
Expand Down
10 changes: 9 additions & 1 deletion posthog/warehouse/api/external_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,15 @@ def database_schema(self, request: Request, *arg: Any, **kwargs: Any):
data={"message": "Cannot use internal Postgres database"},
)

result = get_postgres_schemas(host, port, database, user, password, schema)
try:
result = get_postgres_schemas(host, port, database, user, password, schema)
except Exception as e:
logger.exception("Could not fetch Postgres schemas", exc_info=e)
return Response(
status=status.HTTP_400_BAD_REQUEST,
data={"message": "Could not fetch Postgres schemas. Please check all connection details are valid."},
)

result_mapped_to_options = [{"table": row, "should_sync": False} for row in result]
return Response(status=status.HTTP_200_OK, data=result_mapped_to_options)

Expand Down

0 comments on commit 0d55f92

Please sign in to comment.