@@ -556,19 +556,29 @@ defmodule Supervisor do
556556
557557 Developers typically invoke `Supervisor.init/2` at the end of their
558558 init callback to return the proper supervision flags.
559+
560+ See `start_link/2` for more information.
559561 """
560562 @ callback init ( init_arg :: term ) ::
561563 { :ok ,
562564 { sup_flags ( ) , [ child_spec ( ) | ( old_erlang_child_spec :: :supervisor . child_spec ( ) ) ] } }
563565 | :ignore
564566
565- @ typedoc "Return values of `start_link/2` and `start_link/3`."
567+ @ typedoc """
568+ Return values of `start_link/2` and `start_link/3`.
569+
570+ See the documentation for those functions for more information.
571+ """
566572 @ type on_start ::
567573 { :ok , pid }
568574 | :ignore
569575 | { :error , { :already_started , pid } | { :shutdown , term } | term }
570576
571- @ typedoc "Return values of `start_child/2`."
577+ @ typedoc """
578+ Return values of `start_child/2`.
579+
580+ See the documentation for those functions for more information.
581+ """
572582 @ type on_start_child ::
573583 { :ok , child }
574584 | { :ok , child , info :: term }
@@ -698,15 +708,18 @@ defmodule Supervisor do
698708 If the supervisor and all child processes are successfully spawned
699709 (if the start function of each child process returns `{:ok, child}`,
700710 `{:ok, child, info}`, or `:ignore`), this function returns
701- `{:ok, pid}`, where `pid` is the PID of the supervisor. If the supervisor
702- is given a name and a process with the specified name already exists,
703- the function returns `{:error, {:already_started, pid}}`, where `pid`
704- is the PID of that process.
711+ `{:ok, pid}`, where `pid` is the PID of the supervisor.
712+
713+ If the supervisor is given a name and a process with the specified name
714+ already exists, the function returns `{:error, {:already_started, pid}}`,
715+ where `pid` is the PID of that process.
705716
706- If the start function of any of the child processes fails or returns an error
707- tuple or an erroneous value, the supervisor first terminates with reason
708- `:shutdown` all the child processes that have already been started, and then
709- terminates itself and returns `{:error, {:shutdown, reason}}`.
717+ If the start function of any of the child processes fails or returns
718+ an error tuple or an erroneous value, the supervisor first terminates
719+ with reason `:shutdown` all the child processes that have already been
720+ started, and then terminates itself. If the caller process is trapping
721+ exits, this function then returns
722+ `{:error, {:shutdown, {:failed_to_start_child, id, reason}}}`.
710723
711724 Note that a supervisor started with this function is linked to the parent
712725 process and exits not only on crashes but also if the parent process exits
@@ -939,9 +952,17 @@ defmodule Supervisor do
939952
940953 If the `c:init/1` callback returns `:ignore`, this function returns
941954 `:ignore` as well and the supervisor terminates with reason `:normal`.
942- If it fails or returns an incorrect value, this function returns
943- `{:error, term}` where `term` is a term with information about the
944- error, and the supervisor terminates with reason `term`.
955+
956+ If the `c:init/1` callback fails or returns an incorrect value, the supervisor
957+ will shutdown with reason `term`, where `term` contains information
958+ about the error. If the caller process is trapping exits, this function then
959+ returns `{:error, term()}`.
960+
961+ If the start function of any of the child processes returned by `c:init/1`
962+ fail or return an error tuple or an erroneous value, the supervisor first
963+ terminates with reason `:shutdown` all the child processes that have already
964+ been started, and then terminates itself. If the caller process is trapping
965+ exits, this function then returns `{:error, {:shutdown, {:failed_to_start_child, id, reason}}}`.
945966
946967 The `:name` option can also be given in order to register a supervisor
947968 name, the supported values are described in the "Name registration"
0 commit comments