Skip to content

Improve error messages #29

@harryrose

Description

@harryrose

The status code - error message map in packet.go does not provide detailed enough error messages. Sometimes error messages are misleading, as we receive the message "Command error with status: Unknown variable/method" even when the command failed due to other reasons.

A better approach could be to query the R session and return the message of last error such that the following test passes.

func TestErrorReturn(t *testing.T) {
    con, err := NewRClient("localhost", 6311)
    if err != nil {
        t.Error("Could not connect to RServe: " + err.Error())
        return
    }

    errorText := "this is a test"
    _, err = con.Eval("stop('" + errorText + "')")

    if err == nil {
        t.Error("No error was returned")
    }

    expectedMessage := "Command error with status: " + errorText
    if err.Error() != expectedMessage {
        t.Error("Expected '" + err.Error() + "' to equal '" + expectedMessage + "'")
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions