diff options
author | Tim Beale <timbeale@catalyst.net.nz> | 2019-01-16 15:37:00 +1300 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-02-05 15:33:25 +0100 |
commit | 72e45c8841deae94793ab0e705fcf590e9723fa5 (patch) | |
tree | 2eb8c82c51ea84d6450e0448fc6829a21d0ea50c /python | |
parent | 7acef6b7f43e6d82136bd5c80c782eb6713f280b (diff) | |
download | samba-72e45c8841deae94793ab0e705fcf590e9723fa5.tar.gz |
join: Throw CommandError instead of Exception for simple errors
Throwing an exception here still dumps out the Python stack trace, which
can be a little disconcerting for users.
In this case, the stack trace isn't going to really help at all (the
problem is pretty obvious), and it obscures the useful message
explaining what went wrong.
Throw a CommandError instead, which samba-tool will catch and display
more nicely.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13747
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Rowland Penny <rpenny@samba.org>
Reviewed-by: Jeremy Allison <rpenny@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jan 16 22:11:04 CET 2019 on sn-devel-144
(cherry picked from commit 9e4b08f4c384b8cae5ad853a7be7cf03e2749be5)
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/join.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/python/samba/join.py b/python/samba/join.py index 32fac680b1f..d577df07069 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -42,6 +42,7 @@ import logging import talloc import random import time +from samba.netcmd import CommandError class DCJoinException(Exception): @@ -337,10 +338,10 @@ class dc_join(object): try: ctx.cldap_ret = ctx.net.finddc(domain=domain, flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE) except NTSTATUSError as error: - raise Exception("Failed to find a writeable DC for domain '%s': %s" % - (domain, error.args[1])) + raise CommandError("Failed to find a writeable DC for domain '%s': %s" % + (domain, error.args[1])) except Exception: - raise Exception("Failed to find a writeable DC for domain '%s'" % domain) + raise CommandError("Failed to find a writeable DC for domain '%s'" % domain) if ctx.cldap_ret.client_site is not None and ctx.cldap_ret.client_site != "": ctx.site = ctx.cldap_ret.client_site return ctx.cldap_ret.pdc_dns_name |