Skip to content
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

SSE and Server Errors #36

Closed
elbrujohalcon opened this issue Oct 3, 2014 · 5 comments
Closed

SSE and Server Errors #36

elbrujohalcon opened this issue Oct 3, 2014 · 5 comments
Assignees
Labels
Milestone

Comments

@elbrujohalcon
Copy link
Member

When an SSE endpoint returns an error (e.g. status code 500), it gets listed as an event on shotgun:events.

As an example, consider this code from fiar:

    {ok, Pid1} = shotgun:open("localhost", 8080),

    {ok, Ref1} = shotgun:get( Pid1
                            , "/matches/" ++ Mid ++ "/events"
                            , Headers2
                            , #{ async => true
                               , async_mode => sse}),

    api_call(put, "/matches/" ++ Mid, Headers1, Body),

    [XX] = shotgun:events(Pid1),

    io:format("~p~n", [XX]).

That prints out…

#{headers => [{<<"connection">>,<<"keep-alive">>},
  {<<"server">>,<<"Cowboy">>},
  {<<"date">>,<<"Fri, 03 Oct 2014 13:32:19 GMT">>},
  {<<"content-length">>,<<"0">>}],
  status_code => 500}

It should either throw an exception instead, or shotgun:events should return a response description element (with the headers, status, etc.) besides the list of events.

@elbrujohalcon
Copy link
Member Author

@Euen keep an eye on this one :)

@jfacorro jfacorro modified the milestone: 0.1.5 Oct 22, 2014
@jfacorro
Copy link
Contributor

@elbrujohalcon I'm not sure what return value this describes:

... or shotgun:events should return a response description element (with the headers, status, etc.) besides the list of events.

@elbrujohalcon
Copy link
Member Author

@jfacorro try to get the events from an endpoint that returns 401 and you'll see

@jfacorro
Copy link
Contributor

@elbrujohalcon I meant I'm not sure the desired return value this describes:

... or shotgun:events should return a response description element (with the headers, status, etc.) besides the list of events.

@elbrujohalcon
Copy link
Member Author

@jfacorro maybe besides the reference you get when you start such a request… you can also get the headers, status code, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants