Skip to content

Instantly share code, notes, and snippets.

@junetech
Created December 4, 2019 04:01
Show Gist options
  • Save junetech/e60c26c8b879c982751f98829830b802 to your computer and use it in GitHub Desktop.
Save junetech/e60c26c8b879c982751f98829830b802 to your computer and use it in GitHub Desktop.
Python error raising & args passing
for j in range(2):
try:
for i in range(10):
print(i)
if i == 3:
raise StopIteration
except:
print("raised successfully")
continue
def u_func(i: int):
if i == 0:
raise ValueError(5555)
else:
print(i)
i_list = [1, 0]
for i in i_list:
try:
u_func(i)
except ValueError as err:
print(type(err.args))
print(err.args[0])
print(type(err.args[0]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment