This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-27
Channels
- # beginners (91)
- # cider (1)
- # cljsjs (29)
- # cljsrn (8)
- # clojure (51)
- # clojure-berlin (1)
- # clojure-india (1)
- # clojure-russia (26)
- # clojure-spec (15)
- # clojure-uk (1)
- # clojurebridge (1)
- # clojurescript (240)
- # code-reviews (1)
- # cursive (22)
- # datomic (3)
- # editors (6)
- # emacs (24)
- # figwheel (3)
- # lein-figwheel (57)
- # off-topic (4)
- # om (3)
- # proto-repl (7)
- # protorepl (8)
- # reagent (2)
- # rum (23)
- # slack-help (1)
- # spacemacs (2)
(defn signup-user [pgsql new-user] (when (s/validate schemas/User new-user) (sql/save pgsql new-user)))
in particular, I'd define the exception handler in my routes.clj and this in my controllers.clj (or something similar)
in my example, I'd expect validate to throw an exception if the user doesn't pass the schema check, and save to throw an error if the user already exists
it's just the s/validate will return a truthy value (and thus execute the body) if the schema is valid, and it happens to throw an exception if new-user doesn't match that schema
Hey, I just created a new chestnut project via lein new chestnut my-project
, but after adding datomic I get this error when trying to execute lein repl
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.IllegalArgumentException: No matching ctor found for class clj_logging_config.log4j.proxy$org.apache.log4j.WriterAppender$ff19274a, compiling:(clj_logging_config/log4j.clj:37:18)
I've been stumped for the past couple of hours, I tried adding the log4j as a dependency, as well as following the directions here http://docs.datomic.com/configuring-logging.html
@haywood I don't know for certain, but that looks like it might be a library version conflict. you might run lein deps :tree
and scan for complaints around log4j and/or clj-logging-config
Thanks for the pointers @dominicm and @hiredman! Pretty is nice for exceptions but not much beyond that as far as I can tell. I'll also take a look at fipp and that paper. Maybe an interesting project...
There is the guide http://clojure.org/guides/spec
There are also a number of blogs and screencasts at http://blog.cognitect.com
I'm working on a chapter for the next edition of Programming Clojure but it will be a while before that's available
@alexmiller thanks. I will read it
That's weird and it does look similar to the referenced bug
You're sure you are using latest Clojure? You can use clojure-version to check
Sorry, stars around that as it's a dynamic variable
If you're reproducing on 1.8 or 1.9, prob should file a ticket in jira for it
I’m new to clojure and I specify the Clojure version in lein’s project.clj
Yeah, checking at the repl can help you verify that it matches what you think it is
Ah, I reproduce it too...
I’m sorry, maybe I confused the versions...
yes, but I really don’t understand why
@alexmiller can the spec be good for a beginner to use for solving 4clojure puzzles
Seems unlikely
oke, then I will not use it for that. then I wait till I make "real" programms like a web app
counterpoint - i had a fun time using spec to solve http://adventofcode.com/2015 problems - it wasn’t at all necessary to use spec for any of them really, but i found it a useful exercise for getting muscle memory / familiarity with writing+using specs
i was a beginner to spec but not a beginner to clojure, so my experience with advent of code may not be relevant to the discussion
Is there a reasonable way to get all of the possible ways a substring can be replaced by a different substring? I.e. ab -> xy, ababab -> [xyabab, abxyabab, …] (at most one). I’m guessing this is just going to be manual coding + subs
Doesn't sound too complicated
Just gotta think about the edge cases around overlapping matches