handling of server-side exceptions/error conditions on the client?

38 views
Skip to first unread message

Gert Verhoog

unread,
Oct 9, 2012, 5:25:55 PM10/9/12
to shorele...@googlegroups.com
Hi!

I'm building a Clojurescript application that gets its data from a Clojure server app. Authentication/authorisation are handled server-side, using Chas Emerick's Friend.

If I ask for a piece of data on the server for which I am not authorised, an unauthorised exception is thrown. In a classic server-side application, Ring middleware would catch this exception and either redirect to a login page (when the user is not authenticated), or display an "unauthorised" error message.

In a client-side app that gets its data via XHR requests, things would need to work a little differently.

One possibility would be to have a ring-like middleware stack on the client side, that could be used to observe/intercept/capture/modify responses sent from the remote side. Responses with a certain status (e.g. 401, 403, 404, 5xx) or certain content (a map with an :error key?) could be captured, and an appropriate action could be triggered (e.g. dispatch the event using pub/sub).

My question is: does this sound like a good idea? Does anything like this already exist?

cheers,
gert

Gert Verhoog

unread,
Oct 10, 2012, 2:36:08 AM10/10/12
to shorele...@googlegroups.com
I've actually started working on something like this and so far it's looking promising -- I'll keep you posted :)

gert
> --
>
>

Reply all
Reply to author
Forward
0 new messages