Fork me on GitHub
#yada
<
2016-06-02
>
imre11:06:53

(stupid error description here that I found wasn't what I was looking for)

imre11:06:34

actually scrap that

imre11:06:46

that's not the error I'm looking for

imre11:06:41

but here's another one instead 🙂

imre11:06:53

in an endpoint I want to get params from the path

imre11:06:20

but yada doesn't seem to urldecode paths - is that a conscious decision?

mccraigmccraig12:06:27

@imre: yada is def decoding params from the path and query-string for me - with specs like this - https://www.refheap.com/01eb7208a3283169d6e578761

imre12:06:00

hmmm not sure there is much to decode on uuids?

imre12:06:12

["provider-application/" :id [#".*" :path-to-sub-resource]

imre12:06:54

one of my sub-resources has a ? in its name, so I send a url like .../asdf%3F

imre12:06:29

and yada gives me "asdf%3F" in the param

mccraigmccraig12:06:13

ahhh, i see what you mean @imre - may brain didn't supply the 'url' bit of 'urldecode'... ignore me

imre12:06:29

🙂 no worries

malcolmsparks13:06:45

@imre I believe it's bidi that doing the parameter extraction - there is a reason why bidi does not decode (because there are some situations where you want the encoded version), so it defers the choice to the user (which is a kind of clojure style)

malcolmsparks13:06:57

not sure about query params, I'd have to check the code

malcolmsparks13:06:08

I did once do some auto param decoding in bidi and there were a certain number of users who made valid complaints - it was a while ago and I can't remember the specifics

malcolmsparks13:06:30

@imre can you do your own decoding in this case?

malcolmsparks13:06:38

or is it blocking you?

imre13:06:17

I see your point there, maintaining backwards compatibility

imre13:06:39

although I think url encoding is like escaping strings in code

imre13:06:13

if you want a special character where it has a special meaning, you should encode

imre13:06:16

but IMO the layer that understands the rules of the context should decode them

imre13:06:55

not sure if the ideal point would be bidi or yada - does yada deal with urls directly at all or just relies on bidi to do that?

imre13:06:29

I can do my own for now, it's not a blocker

imre13:06:27

just a supporting example: you ask Java, what the 2nd character (0-based) of "a\nb" is and you'll get b, not n

imre13:06:12

you can always double-encode if you need to go a level up

imre13:06:34

anyway as I said I understand your point

imre13:06:57

is there an extension point maybe where this default behavior could be altered?

imre13:06:50

maybe I could add something to bidi if there isn't

stijn13:06:26

this question isn't really related to yada, but does anyone ever work with manifold streams?

stijn13:06:42

how would you capture errors that happen on a stream?

stijn13:06:03

how can you make a distinction between a stream successfully closing after having processed all elements or a stream being closed because of an error?

stijn13:06:05

am I missing something obvious here?

dominicm14:06:49

@stijn: Not sure if this answers your question, but see things like https://github.com/ztellman/manifold#deferreds where Exceptions are mentioned. Errors can be handled in this way.

mccraigmccraig16:06:54

@stijn: i use streams - i use on-closed and on-drained handlers to clean up, and encode errors in the values on the stream - i don't have any concept of 'complete' though - my streams don't have a logical end

mccraigmccraig16:06:19

you could use sentinel values to represent logical stream ends

richiardiandrea17:06:43

so a question about exceptions again, I have GET with a query param that is a long, when I send a string, I get a yada exception in the yada format:

{
  "status": 400,
  "message": "Bad Request",
  "id": "552fbba4-6f84-4261-884b-113d735a760a",
  "error": {
    "error": "clojure.lang.ExceptionInfo:  {:status 400, :errors ([:query <#C1923ED97>.utils.ErrorContainer{:error {:id (not (integer? a-java.lang.String))}}])}",
    "data": "{:status 400, :errors ([:query <#C1923ED97>.utils.ErrorContainer{:error {:id (not (integer? a-java.lang.String))}}])}"
  }
}

richiardiandrea17:06:53

is there a way to change this behavior?

richiardiandrea17:06:12

or only change the error+data content?

malcolmsparks17:06:12

Yes, you can use 'status responses'. It's in the docs. I'll find a link for you

malcolmsparks17:06:25

Exception handling is a work-in-progress but you can workaround things if you're happy to add your own interceptors

richiardiandrea18:06:41

Thanks Malcom I am checking