Code.ensure_compiled
ensure_compiled
, go back to Code module for more information.
Specs
ensure_compiled(module()) :: {:module, module()} | {:error, :embedded | :badfile | :nofile | :on_load_failure | :unavailable}
Similar to ensure_compiled!/1
but indicates you can continue without said module.
While ensure_compiled!/1
indicates to the Elixir compiler you can
only continue when said module is available, this function indicates
you may continue compilation without said module.
If it succeeds in loading the module, it returns {:module, module}
.
If not, returns {:error, reason}
with the error reason.
If the module being checked is currently in a compiler deadlock,
this function returns {:error, :unavailable}
. Unavailable doesn't
necessarily mean the module doesn't exist, just that it is not currently
available, but it (or may not) become available in the future.
Therefore, if you can only continue if the module is available, use
ensure_compiled!/1
instead. In particular, do not do this:
case Code.ensure_compiled(module) do
{:module, _} -> module
{:error, _} -> raise ...
end
See the module documentation for more information on code loading.