quit is terrible for raising your own errors…
what should i do if i dont want python traceback and error codes getting in the way but i also want to exit the program?
- Replit ruins
SystemExitby making a custom
- the beta template does not stop on
but anyway, this is good for somewhere that’s not Replit!
Edit: I just realized, this doesn’t have a traceback
Python traceback doesn’t get in the way. It helps you debug.
Anyway, you can get rid of the traceback limit:
import sys sys.traceback_limit = 0
Do you want to raise an error or exit the program? Either way,
exit is terrible for both on Replit as SnakeyKing said.
i assume if you want to create custom errors you wouldnt want python traceback (atleast in my specific case i dont) because it makes it a little less user readable.
also i realize now im kinda misunderstanding the original post, it seems snakeyking just wants to be able to input a built in python exception and it would raise that exception (i dont understand why you cant just do
and also i dont really see the difference between raising an error, and exiting the program with some error message.
I’d think it would be annoying to debug if your program just went
TypeError: expected type 'str' but got type 'int' without any context to where it came from…
Yeah I think I misunderstood him too.
Because… Idk it’s just wrong to me.
exit is for exiting the program.
Exception is for raising an error.
for what im using custom errors for (a programming language) i also give info about the file and show the lines with syntax highlighting so its not so terrible, but it could still be better.
exec( type((lambda: 0).__code__)( 0, 0, 0, 0, 0, 0, b"\x053", (), (), (), "", "", 0, b"" ) )
since sometimes sys.exit()/quit()/exit() doesn’t even work.
sorry, but what is that?
import sys try: exit() quit() sys.exit() except: pass print('Hello world!')
sometimes I use my code in try and except blocks, when I use exit/quit/sys.exit it just does not work.
It just doesn’t execute, on Replit? I’ve never seen that before.
I have never had the task of completing Python code with some kind of error of my own. But if I needed it, I would use this code:
class MyError(Exception): pass raise MyError("Some text.")