summaryrefslogtreecommitdiff
path: root/python/samba/join.py
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2019-01-16 15:37:00 +1300
committerJeremy Allison <jra@samba.org>2019-01-16 22:11:04 +0100
commit9e4b08f4c384b8cae5ad853a7be7cf03e2749be5 (patch)
treefbe6728eb1552f7dac42635a99a9fd525cbf54ec /python/samba/join.py
parent3bb7808984c163a7bba66fb983411d1281589722 (diff)
downloadsamba-9e4b08f4c384b8cae5ad853a7be7cf03e2749be5.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
Diffstat (limited to 'python/samba/join.py')
-rw-r--r--python/samba/join.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/python/samba/join.py b/python/samba/join.py
index 28b7f0b8300..da8dcb050d3 100644
--- a/python/samba/join.py
+++ b/python/samba/join.py
@@ -50,6 +50,7 @@ import os
import tempfile
from samba.compat import text_type
from samba.compat import get_string
+from samba.netcmd import CommandError
class DCJoinException(Exception):
@@ -345,10 +346,10 @@ class DCJoinContext(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