Fork me on GitHub
#hoplon
<
2020-12-27
>
GusWill01:12:08

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.

GusWill01:12:18

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

GusWill01:12:29

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?

GusWill01:12:55

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?

alandipert01:12:59

hi, welcome! i think castra is still "valid" in 2020 if you don't mind have a clj-specific backend

alandipert01:12:42

backend errors become exceptions on the client, in the error cell iirc

GusWill01:12:11

Hi @alandipert! Congrats for the great episode, btw! 🎉 I enjoyed learning about a different way of coding front ends.

🙂 1
alandipert01:12:56

thanks, i'm glad you liked it, it was my pleasure. i think i've tried all the ways 😂

GusWill01:12:13

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

GusWill01:12:11

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

GusWill01:12:40

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

alandipert01:12:22

and you don't see anything for :cause ?

GusWill01:12:53

Always nil

GusWill01:12:17

This is the entire exception:

GusWill01:12:19

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

GusWill01:12:53

It's funny because when I inspect the actual transit response, the entire stack trace is there.

alandipert01:12:19

i see some aset business in make-ex, i suspect its setting properties on the ex obj that aren't being pretty printed

alandipert01:12:02

..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

alandipert01:12:16

are you using the examples from the castra readme?

GusWill01:12:19

Is it possible that something in clojurescript changed?

GusWill01:12:31

Yes, examples from the readme

alandipert01:12:34

also possible re: cljs, maybe less likely

GusWill01:12:05

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

GusWill01:12:49

But this always returns "Server error." regardless of the original messaged that was raised in the backend rpc function.

alandipert03:12:56

i have to go, but it sounds like you perhaps got to the bottom of it?

GusWill03:12:04

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

GusWill03:12:54

Thanks for the help @alandipert

alandipert16:12:24

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

GusWill18:12:18

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

👍 1