How to Pass a Terminal error into the Python program whenever the error is triggered in the terminal?
Example:
Consider I'm running a java program and I get some error like this
file.java:2: error: ',', ')', or '[' expected
public static void main(String args...) {
^
1 error
Another example by entering the wrong bash command
ls: option '--a' is ambiguous; possibilities: '--all' '--almost-all' '--author'
Try 'ls --help' for more information.
I need to pass this error to a python program and run the program whenever the terminal shows the error like this.
How can I pass the error?