Quick question. I am trying to write reusable code, and haven't found too many other instances of it coming up. Say a script is looking for an XML file, I could just raise a generic RuntimeException, but I am not sure if it would be informative for others using my code, or even the type of thing they would be likely to catch in an except statement. Any thoughts?
You can make your own exception by extending the base Exception
class.
See: https://docs.python.org/2/tutorial/errors.html#user-defined-exceptions
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.