Skip to content

Instantly share code, notes, and snippets.

@ROBOMASTER-S1
Last active March 7, 2023 05:34
Show Gist options
  • Save ROBOMASTER-S1/163632d30b2e5412eb8388b64714ac91 to your computer and use it in GitHub Desktop.
Save ROBOMASTER-S1/163632d30b2e5412eb8388b64714ac91 to your computer and use it in GitHub Desktop.
Raise Some Errors Python Program Example: Created by Joseph C. Richardson
# Raise a list of possible errors to test in Python programs.
# Created by Joseph C. Richardson, GitHub.com
try:
print('Raising a list of possible errors to test:')
raise Exception
raise ValueError
raise TypeError
raise NameError
raise IndexError
raise MemoryError
except Exception:
print('Exception:')
except ValueError:
print('ValueError:')
except TypeError:
print('TypeError:')
except NameError:
print('NameError:')
except IndexError:
print('IndexError:')
except MemoryError:
print('MemoryError:')
finally:
print('finally always executes no matter the outcome.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment