The :hoplon: ClojureScript Web Framework - http://hoplon.io/
GusWill 2020-12-27T01:12:08.018Z

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.

GusWill 2020-12-27T01:13:18.018900Z

Is Castra/rpc the recommended way in 2020 to communicate with a backend server or should I look into other options?

GusWill 2020-12-27T01:16:29.020800Z

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?

GusWill 2020-12-27T01:18:55.022900Z

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

GusWill 2020-12-27T01:20:11.024500Z

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 😂

GusWill 2020-12-27T01:22:13.026100Z

Ok, so my assumptions were correct. So why do I get "Server error." and not the exception message that I originally threw?

GusWill 2020-12-27T01:23:11.026800Z

I was about to fork and debug this issue, but I hardly think this would be an open issue for 5+ years.

GusWill 2020-12-27T01:24:40.027500Z

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 ?

GusWill 2020-12-27T01:25:53.028100Z

Always nil

GusWill 2020-12-27T01:26:17.028500Z

This is the entire exception:

GusWill 2020-12-27T01:26:19.028700Z

#error {:message "Server error.", :data {:castra.core/exception true}}

GusWill 2020-12-27T01:26:53.029400Z

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?

GusWill 2020-12-27T01:28:19.031100Z

Is it possible that something in clojurescript changed?

GusWill 2020-12-27T01:28:31.031300Z

Yes, examples from the readme


also possible re: cljs, maybe less likely

GusWill 2020-12-27T01:32:05.032700Z

Castra's readme contains this line: (defc= error-message (some-> c/error .-message))

GusWill 2020-12-27T01:34:49.033500Z

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?

GusWill 2020-12-27T03:07:04.034300Z

It took me a while to figure it out, but I think I got it

GusWill 2020-12-27T03:07:54.034600Z

Thanks for the help @alandipert


great, and np! curious to hear about your build tooling when you get a chance

GusWill 2020-12-28T18:53:18.036Z

I just adapted the repo examples to use deps.edn, which is my build tool of preference. The rest is pretty much the same.