• reading errorCode from C level

    From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Fri Apr 26 11:37:45 2024
    From Newsgroup: comp.lang.tcl

    My intention is to switch after an !TCL_OK return value from Tcl_EvalEx() to decide whether a TCL-related error has happend, or some POSIX system
    call error (the cmd called is a "create-socket" call).

    // pseudo code
    Tcl_SetErrno(0); // not sure if that reset is necessary
    if (TCL_OK != Tcl_EvalEx(interp, cmd_str, cmd_size, TCL_EVAL_GLOBAL)) {
    // right now I'm doing:
    if (0 != Tcl_GetErrno()) {
    // assume POSIX error
    } else {
    // assume TCL script level error
    }
    }

    Short of Tcl_ObjGetVar2("errorCode") and looking at the first element of
    the returned list being "POSIX" in case of an error, is there a better way?

    TNX
    R'
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Emiliano Gavilan@emil.g@example.invalid to comp.lang.tcl on Fri Apr 26 09:49:58 2024
    From Newsgroup: comp.lang.tcl

    On Fri, 26 Apr 2024 11:37:45 +0200
    Ralf Fassel <ralfixx@gmx.de> wrote:

    My intention is to switch after an !TCL_OK return value from Tcl_EvalEx() to decide whether a TCL-related error has happend, or some POSIX system
    call error (the cmd called is a "create-socket" call).

    // pseudo code
    Tcl_SetErrno(0); // not sure if that reset is necessary
    if (TCL_OK != Tcl_EvalEx(interp, cmd_str, cmd_size, TCL_EVAL_GLOBAL)) {
    // right now I'm doing:
    if (0 != Tcl_GetErrno()) {
    // assume POSIX error
    } else {
    // assume TCL script level error
    }
    }

    Short of Tcl_ObjGetVar2("errorCode") and looking at the first element of
    the returned list being "POSIX" in case of an error, is there a better way?

    Tcl_GetReturnOptions()
    --
    Emiliano
    --- Synchronet 3.20a-Linux NewsLink 1.114