-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to receive mirage's error msg on client #4
Comments
You should be able to send data to the client: primus.id.validator(function validate(spark, fn) {
if (spark.mirage === 'old') return fn(undefined, 'new');
if (spark.mirage === 'new') return fn(undefined, 'old');
var err = new Error('The id is neither new or old');
spark.emit('mirage error', err.message);
fn(err);
}); With the auth hook the error message is automatically sent to the client. |
So, 'spark' is active in validator. Does spark.write properly work here as well? I was under the impression that communication with client is only possible inside/after 'connection' event (which I believe is only emitted once .validator returns with success). Auth errors:I got confused by "Unfortunately, the amount of detail you get in your client when authorization fails depends on the transformer in use. Most real-time frameworks supported by Primus don't expose the status code, headers or response body." at https://github.com/primus/primus#client. I'm using Engine.io (any issues?). However, I also did some testing and the actual error code/msg server sent is printed from somewhere inside the primus client lib and I did not receive it in 'error' or 'unexpected-response' events. How do I access through 'primus' client object on client.
From 'error' event on client, I get.
then, there is stack trace. FYI: the status code is 503, 401 etc. |
The documentation is correct, if you use Engine.IO and the auth hook, in your So it doesn't work out of the box.
|
On the client, is there any way I could access the error message/object that was returned by validator() method?
I am trying to make sure accounts are in a specific state but I need to know where/how validator function failed? I could have done it in authentication middleware but I can still not detect the error message there (or correct me if I am wrong).
I was thinking if we could have an event thrown on client something like 'mirage error' with this error object then that would solve this problem.
The text was updated successfully, but these errors were encountered: