Reputation: 283
In the below python the message RSU is not supported on single node machine** is not getting printed. can anyone help please??
#! /usr/bin/env python
import sys
class SWMException(Exception):
def __init__(self, arg):
print "inside exception"
Exception.__init__(self, arg)
class RSUNotSupported(SWMException):
def __init__(self):
SWMException.__init__(self, "**RSU is not supported on single node machine**")
def isPrepActionNeeded():
if 1==1:
raise RSUNotSupported()
try:
isPrepActionNeeded()
except:
sys.exit(1)
Upvotes: 1
Views: 345
Reputation: 176980
Change the last two lines to:
except Exception as e:
print e
sys.exit(1)
I use just Exception
here to keep this the equivalent of a bare except:
. You really should use RSUNotSupported
so you don't hide other types of errors.
Upvotes: 0
Reputation: 22679
It is not printed, because you're even not trying to print it :) Here:
try:
isPrepActionNeeded()
except RSUNotSupported as e:
print str(e)
sys.exit(1)
Upvotes: 2