Fork me on GitHub
#hoplon
<
2016-07-28
>
levitanong14:07:17

Hey guys! Castra question: How can I prevent a stacktrace (in the event of an error) from being sent clientside, and instead write it to log? Perhaps an rpc/error config alongside :rpc/pre and rpc/query?

raywillig15:07:07

@levitanong: wouldn’t try/catch on your server side functions handle that?

raywillig15:07:24

along with clojure.tools.logging or whatever the ns is called

levitanong16:07:12

@raywillig: So you mean like, not throwing an exception at all, and just placing the logging code in the catch clause?

micha16:07:19

yeah i can see the need for a stack trace expunging mode for production

raywillig16:07:37

@levitanong: yeah you could catch the exception log it and then throw a more palatable exception to your front end app

micha16:07:16

i think the issue here is the stack trace

micha16:07:47

wrapping exceptions in castra exceptions is how you would return a better error message

levitanong16:07:42

@micha Yeah this is for a client. (That’s right folks, hoplon-castra is in data-heavy enterprise software!)

micha16:07:49

seems like this should be an option when you construct the castra middleware

levitanong16:07:46

That’s exactly what my colleague, @syk0saje seems to be planning on doing.

levitanong16:07:36

Something about dfl-ex

micha17:07:21

perhaps a :verbosity option

micha17:07:37

that's kind of what it is, i think

micha17:07:58

ah the dfl-ex is interesting

micha17:07:04

but not completely related

micha17:07:24

still good to have, but it won't fix the stack trace issue, because any exception will have a trace associated with it

micha17:07:04

or maybe a :quiet option, to remove extra metadata from the responses, like stack traces, etc

levitanong17:07:07

That would be great 😄

syk0saje17:07:49

i made middleware to log exceptions and strip them from castra responses

syk0saje17:07:05

at least anything sensitive like the stack trace

syk0saje17:07:10

i keep the message there

syk0saje17:07:11

also not sure if i'm using the clj<->json converters right. i'm not passing in a first argument since i'm not sure if anything has to be there

syk0saje17:07:58

ah shoot hang on this code messes up on non-castra requests lol

syk0saje17:07:58

added a try catch, but yeah this is just a workaround until something like :quiet is available for wrap-castra

alandipert18:07:16

@kenneth: taking a look at your issue now - tricky one!

alandipert18:07:18

@kenneth: i came up with this workaround:

(defn if-toggle
  [predc then else]
  (div (then :toggle predc)
    (else :toggle (cell= (not predc)))))