Hello I’m trying to write my first hex package for I will be able to reuse it easily in several projects.
I know I can set the module name in question with config file, but I would like to set at least a default value in the hex package config.
For example if the phoenix project main app name is :myapp I would like to call by default (if any config is not set) the module MyappWeb.ErrorHelpers.
I get it, thanks for this explanation.
I will cheat a bit on following library that does pretty much the same thing as my hex package.
@error_message """
Missing translate_error_module config. Add the following to your config/config.exe
config :formulator, translate_error_module: YourAppName.Gettext
"""
defp translate_error(error) do
if module = Application.get_env(:formulator, :translate_error_module) do
module.translate_error(error)
else
raise ArgumentError, message: @error_message
end
end