How can I make this script catch errors?

  • John

    I have this PythonScript script written:

    import sys
        notepad.runMenuCommand('Run', 'Run in Python (no console)')
        sys.stdout = console
        sys.stderr = console

    What I want is for the console to appear and display any errors, if there are any, otherwise, no console. However, as written (and a few other ways) it does not work.

    What I currently have as the "Run in Python (no console)" macro is simply to run the open file using pythonw.exe. This works when there are no errors in the file, but if there's an error, then nothing at all happens. I can get the error output if I run the file with  IDLE, but not this way. I'd like to see the error message in the PythonScript console if possible.


  • Karim Hamza
    Karim Hamza

    the run command in npp doesn't stdout the errors.
    the command itself doesn't support writing to the stdout
    (i think it has something to do with how npp run commands, it uses shellexcute and this doesn't support stdout)

    so i think you shouldn't run the pythonw.exe through the npp run command . instead find away to run it through the python script itself