@@ -3596,15 +3596,20 @@ public void addBulkImportUsers(AppIdentifier appIdentifier, List<BulkImportUser>
35963596 try {
35973597 BulkImportQueries .insertBulkImportUsers_Transaction (this , (Connection ) con .getConnection (), appIdentifier , users );
35983598 } catch (SQLException e ) {
3599- if (e instanceof PSQLException ) {
3600- ServerErrorMessage serverErrorMessage = ((PSQLException ) e ).getServerErrorMessage ();
3601- if (isPrimaryKeyError (serverErrorMessage , Config .getConfig (this ).getBulkImportUsersTable ())) {
3602- throw new StorageTransactionLogicException (new io .supertokens .pluginInterface .bulkimport .exceptions .DuplicateUserIdException ());
3603- }
3604- if (isForeignKeyConstraintError (serverErrorMessage , Config .getConfig (this ).getBulkImportUsersTable (),
3605- "app_id" )) {
3606- throw new TenantOrAppNotFoundException (appIdentifier );
3599+ if (e instanceof BatchUpdateException ) {
3600+ BatchUpdateException batchUpdateException = (BatchUpdateException ) e ;
3601+ SQLException nextException = batchUpdateException .getNextException ();
3602+ if (nextException instanceof PSQLException ){
3603+ ServerErrorMessage serverErrorMessage = ((PSQLException ) nextException ).getServerErrorMessage ();
3604+ if (isPrimaryKeyError (serverErrorMessage , Config .getConfig (this ).getBulkImportUsersTable ())) {
3605+ throw new StorageTransactionLogicException (new io .supertokens .pluginInterface .bulkimport .exceptions .DuplicateUserIdException ());
3606+ }
3607+ if (isForeignKeyConstraintError (serverErrorMessage , Config .getConfig (this ).getBulkImportUsersTable (),
3608+ "app_id" )) {
3609+ throw new TenantOrAppNotFoundException (appIdentifier );
3610+ }
36073611 }
3612+
36083613 }
36093614 }
36103615 return null ;
0 commit comments