Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nil component #39

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Nil component #39

wants to merge 14 commits into from

Conversation

darkleaf
Copy link
Owner

@darkleaf darkleaf commented Dec 17, 2024

closes #38
fixes #37

test/darkleaf/di/component_test.clj Outdated Show resolved Hide resolved
src/darkleaf/di/core.clj Outdated Show resolved Hide resolved
src/darkleaf/di/core.clj Outdated Show resolved Hide resolved
src/darkleaf/di/core.clj Outdated Show resolved Hide resolved
@darkleaf
Copy link
Owner Author

@KGOH @slaughtlaught fyi

@KGOH KGOH marked this pull request as draft December 18, 2024 12:34
@slaughtlaught slaughtlaught marked this pull request as ready for review December 20, 2024 10:04
@@ -13,6 +13,11 @@
;; It throws with original exception.
;; All other possible exceptions are added as suppressed.

(defn ex-map-wo-via [ex]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darkleaf обрати внимание, мб лучше можно сделать

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KGOH @slaughtlaught you all could simple use ex-cause

(defn- validate-component-obj! [obj variable]
(when (nil? obj)
(throw (ex-info "A component fn should not return nil"
{:variable variable}))))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я не смог придумать нормальный :type.
И там ниже в var->factory-defn тоже нет type.

Если сможете придумать, будет здорово, нет - тоже ок.

(t/deftest nil-component-0-arity-test
(let [ex (try-catch (di/start `nil-component-0-arity))]
(t/is (= "An error during component build" (-> ex ex-message)))
(t/is (= "A component fn should not return nil" (-> ex ex-cause ex-message)))))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use "must not"?
For example clojure.core contains "must" several times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing error message when component returns nil
3 participants