Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Comments

Send error message to client#11

Open
adlerparnas wants to merge 1 commit intoOrange-OpenSource:masterfrom
adlerparnas:patch-1
Open

Send error message to client#11
adlerparnas wants to merge 1 commit intoOrange-OpenSource:masterfrom
adlerparnas:patch-1

Conversation

@adlerparnas
Copy link

I believe that if you returned an error as a response to a call, you should be able to read the error on the client

I believe that if you returned an error as a response to a call, you should be able to read the error on the client
@speigg
Copy link

speigg commented Sep 30, 2015

👍

@speigg
Copy link

speigg commented Sep 30, 2015

Actually this is still wrong, look at the spec:
https://github.com/wamp-proto/wamp-proto/blob/master/spec/basic.md#invocation-error

[ERROR, INVOCATION, INVOCATION.Request|id, Details|dict, Error|uri]
or

[ERROR, INVOCATION, INVOCATION.Request|id, Details|dict, Error|uri, Arguments|list]
or

[ERROR, INVOCATION, INVOCATION.Request|id, Details|dict, Error|uri, Arguments|list, ArgumentsKw|dict]

So, "wamp.error.callee_failure" should be replaced by err, and the additional parameters should also be added to the error message (args and kwargs, if they exists)

@speigg
Copy link

speigg commented Sep 30, 2015

I believe this would be correct:

var resultCallback = function(err, args) {
        var msg;
        if (err) {
            msg = [
                WAMP.ERROR,
                WAMP.CALL,
                callId,
                {},
                err
            ];
        } else {
            msg =  [
                WAMP.RESULT,
                callId,
                {},
            ];
        }
        // Manage optional parameters args + kwargs
        for(var i = 0; i < args.length && i < 2; i++) {
            msg.push(args[i]);
        }
        session.send(msg);
};

@speigg
Copy link

speigg commented Sep 30, 2015

The other problem with sending errors is in handlers[WAMP.ERROR]

handlers[WAMP.ERROR] = function(session, msg) {
    var requestType = msg.shift();
    var requestId = msg.shift();
    var details = msg.shift();
    var errorUri = msg.shift();
    var args = msg.shift() || [];
    var kwargs = msg.shift() || {};

    var err = new Error(details);   // <--- this line
    if (requestType === WAMP.INVOCATION) {
        // An invocation failed
        var invId = requestId;
        this.resrpc(invId, err, args); // <--- only err and args objects passed?
    }

}

Several problems:

  1. details are converted to an Error object, so this immediately becomes unusable for routing to the Caller (Error objects are not meaningfully JSON.stringified).
  2. errorUri and kwargs are ignored? surely these should also be routed to the Caller.

@speigg speigg mentioned this pull request Oct 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants