2
A
回答
4
您可以使用dire来做到这一点。您应该看看它对preconditions的支持。
0
如果你不想依赖外部库,clojure的(assert)
支持一个可选的消息。
的缺点是,你将失去一个:pre
的可读性,必须将结果保存为:post
检查中间变量(或在某些宏魔术包起来)。
简单的例子:
(defn mysqrt [x]
;; preconditions
(assert (pos? x) "Positive numbers only")
(let [y (Math/sqrt x)]
;; postconditions
(assert (number? y) "Some strange error happened")
y))
相关问题
- 1. 自定义错误消息
- 2. jqgrid中的自定义错误消息
- 3. 节点断言:测试错误消息
- 4. Grails域的自定义错误消息
- 5. HTTPStatusCodeResult&jQuery的自定义错误消息
- 6. python argparse - 自定义错误消息
- 7. 用自定义消息替换错误
- 8. Ghost:自定义错误消息
- 9. JWPLAYER自定义错误消息
- 10. Vaadin自定义错误消息
- 11. Python Click:自定义错误消息
- 12. Zend_Form自定义错误消息
- 13. 自定义Spring错误消息
- 14. has_secure_password自定义错误消息
- 15. kohana自定义验证错误消息
- 16. 使用simple_form自定义错误消息
- 17. asp.NET - 自定义错误消息
- 18. WF ThrowActivities和自定义错误消息?
- 19. 自定义JAXB验证错误消息
- 20. jQuery验证自定义错误消息
- 21. 自定义错误消息8
- 22. Struts2自定义错误消息
- 23. 如何自定义错误消息
- 24. 自定义authlogic错误消息
- 25. Rails 4.2 ActionController:BadRequest自定义错误消息
- 26. 自定义NSFormatter和错误消息
- 27. 自定义关联错误消息
- 28. 设计,自定义错误消息?
- 29. 自定义错误消息和Laravel 5.1
- 30. Php Mysqli自定义错误消息