This is an application design decision that will depend on how you want to
handle failure in general.
If the application cannot run without being able to start the component,
then it is appropriate to throw an exception from the component's `start`
method. This will abort the system start. The component library wraps the
exception with ex-info containing the component that failed AND the
complete system so far, including components which were successfully
started How you want to handle that exception is up to you.
In production, I would handle this by calling System/exit with a non-zero
status code from my `main` method.
During development, if a component fails to start, it may leave the rest of
the system in an inconsistent state. This may make it difficult to restart
the system because of old state from the half-started system. For example,
a web server may have bound to a socket. Technically you could use the
system object attached to the exception to clean up the state manually, but
I usually just restart the REPL.
If the application could continue to operate successfully without that
component, it's much more complicated. You're on your own here;
the 'component' library doesn't have any functions to help with
partially-failed systems.
–S
On Wednesday, December 23, 2015 at 1:42:21 PM UTC-5, fahptv wrote:
>
> If a component discovers it cannot start successfully (e.g. some necessary
> bit of data is badly formatted), how can it tell the system that it's hosed
> and therefore all dependents are hosed?
>
> Should it throw an exception to stop everything?
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.