Hey guys! I recently learned about Hoplon through a Clojurescript podcast interview with @alandipert. I've been digging through the docs and I'm a little confused about Castra integration. I have a few questions that hopefully someone here can answer.
Is Castra/rpc the recommended way in 2020 to communicate with a backend server or should I look into other options?
Using this snippet (https://github.com/hoplon/hoplon/wiki/Castra) to show business logic errors like "password mismatch" I always get "Server error.". What am I doing wrong?
The way I understand it is that my rpc function should be given 3 cells: result
, error
and loading
. Should error
contain business logic errors and, therefore, my backend rpc function should raise exceptions, or should error
be restricted only to server errors?
hi, welcome! i think castra is still "valid" in 2020 if you don't mind have a clj-specific backend
backend errors become exceptions on the client, in the error cell iirc
Hi @alandipert! Congrats for the great episode, btw! 🎉 I enjoyed learning about a different way of coding front ends.
cc @micha ⬆️
thanks, i'm glad you liked it, it was my pleasure. i think i've tried all the ways 😂
Ok, so my assumptions were correct. So why do I get "Server error." and not the exception message that I originally threw?
I was about to fork and debug this issue, but I hardly think this would be an open issue for 5+ years.
So ig I'm probably doing something wrong, but I can't figure out what. This is the message that I always get: https://github.com/hoplon/castra/blob/master/src/castra/core.cljs#L94
and you don't see anything for :cause ?
Always nil
This is the entire exception:
#error {:message "Server error.", :data {:castra.core/exception true}}
It's funny because when I inspect the actual transit response, the entire stack trace is there.
i see some aset
business in make-ex
, i suspect its setting properties on the ex obj that aren't being pretty printed
..maybe. to your point about a bug for 5+ yrs, i think it's likeliest the example is stale, since i know ppl are using the code
are you using the examples from the castra readme?
Is it possible that something in clojurescript changed?
Yes, examples from the readme
also possible re: cljs, maybe less likely
Castra's readme contains this line: (defc= error-message (some-> c/error .-message))
But this always returns "Server error." regardless of the original messaged that was raised in the backend rpc function.
i have to go, but it sounds like you perhaps got to the bottom of it?
It took me a while to figure it out, but I think I got it
Thanks for the help @alandipert
great, and np! curious to hear about your build tooling when you get a chance
I just adapted the repo examples to use deps.edn, which is my build tool of preference. The rest is pretty much the same.