Skip to content

Improve error messages when something goes wrong #5388

@sylver

Description

@sylver

Environment

  • Elixir version (elixir -v):
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.3.4
  • Operating system:
    masOS Sierra 10.12

Current behavior

I'm making an umbrella app and I'm using env variables to set a few parameters I need to tweak for my builds in all the apps of the project. Here's an example :

  def project do
    [app: :auth,
     version: "0.1.0",
     build_path: System.get_env("BUILD_PATH"),
     config_path: "../../config/config.exs",
     deps_path: System.get_env("DEPS_PATH"),
     lockfile: "../../mix.lock",
     elixir: "~> 1.3",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix, :gettext] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     aliases: aliases(),
     deps: deps()]
  end

If some parameters in the mix.exs file are wrong (I have tried with build_pathand config_path so far), the error messages aren't helping at all to debug why an exception is raised.

If no build_path and deps_path are set we get :

$> mix deps.get
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
    (elixir) lib/io.ex:412: IO.chardata_to_string(nil)
    (elixir) lib/path.ex:619: Path.expand_home/1
    (elixir) lib/path.ex:139: Path.expand/1
    (mix) lib/mix/project.ex:83: Mix.Project.deps_config/1
    (mix) lib/mix/dep.ex:167: Mix.Dep.in_dependency/3
    (mix) lib/mix/dep/loader.ex:55: Mix.Dep.Loader.load/2
    (mix) lib/mix/dep/converger.ex:179: Mix.Dep.Converger.all/9
    (mix) lib/mix/dep/converger.ex:114: Mix.Dep.Converger.all/7

If build_path and deps_path are set, but with invalid directories, we get :

$> mix deps.get
Running dependency resolution
Dependency resolution completed
  base64url: 0.0.1
  comeonin: 2.6.0
  connection: 1.0.4
  cowboy: 1.0.4
  cowlib: 1.0.2
  db_connection: 1.0.0
  decimal: 1.2.0
  ecto: 2.0.5
  ex_machina: 1.0.2
  fs: 0.9.2
  gettext: 0.12.1
  guardian: 0.13.0
  jose: 1.8.0
  mime: 1.0.1
  phoenix: 1.2.1
  phoenix_ecto: 3.0.1
  phoenix_html: 2.7.0
  phoenix_live_reload: 1.0.0
  phoenix_pubsub: 1.0.1
  plug: 1.2.2
  poison: 2.2.0
  poolboy: 1.5.1
  postgrex: 0.12.1
  ranch: 1.2.1
  uuid: 1.1.5
* Getting phoenix (Hex package)
  Checking package (https://repo.hex.pm/tarballs/phoenix-1.2.1.tar)
  Fetched package
** (exit) an exception was raised:
    ** (MatchError) no match of right hand side value: {:error, :enoent}
        (stdlib) erl_tar.erl:870: :erl_tar.write_file/2
        (stdlib) erl_tar.erl:810: :erl_tar.write_extracted_element/3
        (stdlib) erl_tar.erl:598: :erl_tar.extract1/4
        (stdlib) erl_tar.erl:571: :erl_tar.foldl_read1/4
        (stdlib) erl_tar.erl:554: :erl_tar.foldl_read0/4
        (stdlib) erl_tar.erl:546: :erl_tar.foldl_read/4
        (hex) lib/hex/tar.ex:95: Hex.Tar.extract_contents/3
        (hex) lib/hex/tar.ex:44: Hex.Tar.unpack/3
    (stdlib) erl_tar.erl:556: :erl_tar.foldl_read0/4
    (stdlib) erl_tar.erl:546: :erl_tar.foldl_read/4
    (hex) lib/hex/tar.ex:95: Hex.Tar.extract_contents/3
    (hex) lib/hex/tar.ex:44: Hex.Tar.unpack/3
    (hex) lib/hex/scm.ex:110: Hex.SCM.checkout/1
    (mix) lib/mix/dep/fetcher.ex:64: Mix.Dep.Fetcher.do_fetch/3
    (mix) lib/mix/dep/converger.ex:174: Mix.Dep.Converger.all/9
    (mix) lib/mix/dep/converger.ex:183: Mix.Dep.Converger.all/9

Expected behavior

Expecting mix to have an overall better errors/exceptions handling, and to eventually be able to explicitly point out what's wrong in the configuration file (in the case it's a configuration issue like here).

I know i'm only doing a reporting without having investigate in the code or came up with a pull request for this already, I'd like to, but don't have the time right now, sorry about that. Maybe later if you guys don't have worked on this yet.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions