1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Except Hook not working correctly with Vscode debugger

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 20:32.

  1. Stack

    Stack Membro Participativo

    I'm trying to make a library for python and I want to add custom exceptions, but every time I raise an exception, the exception shows my raise as the problem.

    For example:

    Traceback (most recent call last):
    File "c:\Users\james\Desktop\mylibrary\testing.py", line 16, in <module>
    'the library user doing absolute shit'
    File "c:\Users\james\Desktop\mylibrary\mylibrary\__init__.py", line 100, in function_name
    else: raise errors.myerror('Text about my custom error')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    errors.myerror: Text about my custom error


    I manage to solve this problem using sys.excepthook and no VSCode debugger (Run Without Debugging):

    Traceback (most recent call last):
    File "c:\Users\james\Desktop\mylibrary\testing.py", line 16, in <module>
    'the library user doing absolute shit'
    errors.myerror: Text about my custom error


    But when i use the VSCode debugging tool (Start Debugging) it say again that the problem come from my raise.

    Continue reading...

Compartilhe esta Página