Closed 27leaves closed 5 years ago
I believe throwing a WampErrorException
will allow you to control the WAMP error details that get sent back to the caller.
Thank you, but for that I would need an InvocationMessage
and for that some information that I do not have at that point.
OK, it works like that
throw new WampInvocationException(
new InvocationMessage(InvocationMessage.MSG_INVOCATION, 0, {}, args, argskw),
'my.error.trysomething',
args,
argskw,
{
error: `Some error description`
}
);
that on the other side this releases:
Error {
error: 'my.error.trysomething',
args: [],
kwargs: { code: 'd126' }
}
Seems like the only information that I don't have at that point is the registrationId
. Don't I need that? And the details are not passed, but I guess that's by design?
It should be easier than that to throw an exception. I’ll take a look at it later today.
On Fri, Apr 19, 2019 at 12:06 PM Johannes Herrnegger < notifications@github.com> wrote:
OK, it works like that
throw new WampInvocationException(new InvocationMessage(InvocationMessage.MSG_INVOCATION, 0, {}, args, argskw), 'my.error.trysomething', args, argskw, { error:
Some error description
} );that on the other side this releases:
Error { error: 'my.error.trysomething', args: [], kwargs: { code: 'd126' } }
Seems like the only information that I don't have at that point is the registrationId. Don't I need that? And the details are not passed, but I guess that's by design?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/voryx/thruway.js/issues/24#issuecomment-484943241, or mute the thread https://github.com/notifications/unsubscribe-auth/ABF5FXYMVO3UJZ25NTPX4KDPRHUY3ANCNFSM4HHEYNLQ .
This should work:
async function trysomething(a, b) {
throw new WampErrorException('my.error.trysomething', ['arg1', 'arg2']);
}
How do you plan on using the registrationId
?
We limit what is sent back with the error message to limit the possibility of accidentally leaking information. You have fine grain control over everything with WampErrorExeption
.
Oh yes, that should be sufficient.
I do not need the registrationId
. I just would have needed it on using WampInvocationException
with InvocationMessage
.
Thank you! :)
When I try to throw an Exception like
then the Error I get on the other side is
Is there a way to raise another error or provide details about the Error on side that calls the function?
Thanks!