Pyramid's Response Errors and iOS NSError

49 views
Skip to first unread message

Zak

unread,
Aug 19, 2012, 8:21:42 AM8/19/12
to pylons-...@googlegroups.com
I've built an iOS app that's powered by data proved by Pyramid. How can I use Pyramid's error framework such as

    self.request.response.status = 400
    return json.dumps( { 'error' : 'The server was sent bad parameters!'}, default=json_util.default)

to correctly populate an NSError? Specifically, putting an error message in NSError's userDict and extracting it via [error localizedDescription]? So far every time I've tried, userDict is completely null. What am I doing wrong?

Zak

unread,
Aug 20, 2012, 4:20:00 PM8/20/12
to pylons-...@googlegroups.com
Are there no other iOS developers on the mailing list? I would think at least a few of you would have run into a situation like this. It would be really useful to return your own custom 400 error responses and have the app interpret them.

Michael Merickel

unread,
Aug 20, 2012, 5:43:33 PM8/20/12
to pylons-...@googlegroups.com
This is more to do with your iOS parsing than anything to do with Pyramid.

For example, I have code in iOS that attempts to parse the response,
pull out the payload, etc of a JSON-RPC response. If any of those
fails I generate an NSError object, but they all have a similar syntax
of:

NSError *error = [NSError errorWithDomain:<some domain> code:<some
code> userInfo:[NSDictionary dictionaryWithObjectsAndKeys:<some error
message>, NSLocalizedDescriptionKey, nil]];
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/TmYzck3NSr4J.
>
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discus...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
Reply all
Reply to author
Forward
0 new messages