Skip to content

Instantly share code, notes, and snippets.

@Lord-Giganticus
Last active January 8, 2021 16:49
Show Gist options
  • Save Lord-Giganticus/db95058abbd54b198061902a4f6b6d7c to your computer and use it in GitHub Desktop.
Save Lord-Giganticus/db95058abbd54b198061902a4f6b6d7c to your computer and use it in GitHub Desktop.
A small python function to handle exceptions.

error.py by @Lord-Giganticus.

Usage: from error import error and:

except:
  error.problem(interger, interger)

if it's a input error, instead do:

except:
 error.problem(interger, 0)
# Made by Lord-Giganticus
class error:
def problem(x:int, y:int):
if y == 0:
print("There was a input error on line",str(x)+'.')
elif y != 0 and y > 0:
print('There was a error somewhere between line',str(x),'and line',str(y)+'.')
elif y != 0 and y < 0:
print('y is less than 0! It is set to',str(y),'and x is set to',str(x)+'. Please inform the author that this has occured!')
input('Press enter to exit.')
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment