Improve exception handling ... the 'real' traceback is shown by the parent scope, but was lost in the current code because we triggered another exception

This commit is contained in:
Alexandre Aubin 2019-03-05 00:31:01 +01:00
parent 59714fdb1b
commit 47e6bf95dd
2 changed files with 4 additions and 5 deletions

View file

@ -339,11 +339,10 @@
"migration_0009_can_not_backup_before_migration": "The backup of the system before the migration failed. Migration failed. Error: {error:s}",
"migration_0009_create_group": "Create group for each user.",
"migration_0009_done": "Migration sucess. You are now able to use groups of user.",
"migration_0009_failed": "Migration failed.",
"migration_0009_LDAP_update_failed": "LDAP update failed. Error: {error:s}",
"migration_0009_migrate_permission": "Migrate permission from apps settings to LDAP",
"migration_0009_migration_failed_try_rollback": "Migration failed. Try to restore the system. Error: {error:s}",
"migration_0009_rollback_success": "System restored.",
"migration_0009_migration_failed_trying_to_rollback": "Migration failed ... trying to rollback the system.",
"migration_0009_rollback_success": "Rollback succeeded.",
"migration_0009_update_LDAP_database": "Update LDAP database for groups and permission support",
"migration_0009_update_LDAP_schema": "Update LDAP schema",
"migrations_backward": "Migrating backward.",

View file

@ -124,7 +124,7 @@ class MyMigration(Migration):
permission_sync_to_user(auth)
except Exception as e:
logger.warn(m18n.n("migration_0009_migration_failed_try_rollback", error=e))
logger.warn(m18n.n("migration_0009_migration_failed_trying_to_rollback"))
os.system("systemctl stop slapd")
os.system("rm -r /etc/ldap/slapd.d") # To be sure that we don't keep some part of the old config
os.system("cp -r --preserve %s/ldap_config/. /etc/ldap/" % backup_folder)
@ -133,7 +133,7 @@ class MyMigration(Migration):
os.system("systemctl start slapd")
os.system("rm -r " + backup_folder)
logger.info(m18n.n("migration_0009_rollback_success"))
raise YunohostError("migration_0009_failed")
raise
os.system("rm -r " + backup_folder)