Hello nim community,

I'm playing with nim and came across a problem. I'm not sure what's wrong with 
my code (see below). I'm bulding cron backoff utility, which takes a command 
and some arguments from the user and than executes it. If the user passed wrong 
command, the `startProcess` raises OSError, that is fine. But I suppose that 
the errorCode of that exception will correspond to the error. I want to 
distunguish 1) if the command could no be found 2) another error, like 
permission issues.

I've created a test case. If I run non-existing command, the OSError exception 
message is: `Additional info: Could not find command: 'lsaaa'. OS error: No 
such file or directory`. If command is not executable the message is: 
`Additional info: Could not find command: './run.sh'. OS error: Permission 
denied`

**BUT errorCode is always 0. Is this expected?**

I'm running linux.
    
    
    import std/osproc
    import std/oserrors
    
    var command = "lsaaa"
    var args = @["-lah"]
    
    try:
        let process = startProcess(command, args = args, options = {poUsePath, 
poParentStreams})
        echo "WAITING..."
        echo process.waitForExit()
    except OSError as e:
        echo "ERROR CODE:", e.errorCode
        echo OSErrorCode(e.errorCode)
        echo e.msg
    
    
    Run

Thank you.

M.

Reply via email to