Owl [he/him] to [email protected]English • 10 months agoslicing arrayshexbear.netimagemessage-square20fedilinkarrow-up157
arrow-up157imageslicing arrayshexbear.netOwl [he/him] to [email protected]English • 10 months agomessage-square20fedilink
minus-squarehexaflexagonbear [he/him]linkfedilinkEnglish3•edit-210 months agoAt some point I’m just gonna give up and do Try: Entire fucking program Except: Print(“error: something went wrong”)
minus-squareinvalidusernamelol [he/him]linkfedilinkEnglish4•edit-210 months agoEven better is to create a decorator and just wrap the offending functions: def shut_up(func): def call(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: print(f"shit's fucked, but I'll be quiet about it") return return call @shut_up def add(x: int, y: int): print(x + y) add(1, 2) add(-1, 2) add(1, "2") >>> 3 >>> 1 >>> "shit's fucked, but I'll be quiet about it" Or if you want to attempt to salvage it: def shut_up(func): def call(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: try: return func(*map(int, args), **kwargs) except Exception as e: print(f"shit's really fucked, I even tried to fix it for you") return None return call
At some point I’m just gonna give up and do
Try:
Entire fucking program
Except:
Print(“error: something went wrong”)
Even better is to create a decorator and just wrap the offending functions:
Or if you want to attempt to salvage it: