Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在这个Elixir程序中需要:错误模式匹配?_Elixir - Fatal编程技术网

为什么在这个Elixir程序中需要:错误模式匹配?

为什么在这个Elixir程序中需要:错误模式匹配?,elixir,Elixir,我只是试图从编程Elixir 1.0中运行一个示例Elixir程序,并得到以下错误,尽管这样做似乎不应该: 我做错了什么 我执行iex-S混合并查看错误报告: Erlang/OTP18[erts-7.2][source][64位][smp:8:8][async threads:10][hipe][kernel poll:false] =INFO REPORT==== 2-Apr-2016::20:11:46 === application: logger exited: stop

我只是试图从编程Elixir 1.0中运行一个示例Elixir程序,并得到以下错误,尽管这样做似乎不应该:

我做错了什么

我执行iex-S混合并查看错误报告:

Erlang/OTP18[erts-7.2][source][64位][smp:8:8][async threads:10][hipe][kernel poll:false]

=INFO REPORT==== 2-Apr-2016::20:11:46 ===
    application: logger
    exited: stopped
    type: temporary
** (Mix) Could not start application sequence_supervisor: exited in: SequenceSupervisor.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, Sequence.Server, {:EXIT, {:undef, [{Sequence.Server, :start_link, '{', []}, {:supervisor, :do_start_child, 2, [file: 'supervisor.erl', line: 343]}, {:supervisor, :start_children, 3, [file: 'supervisor.erl', line: 326]}, {:supervisor, :init_children, 2, [file: 'supervisor.erl', line: 292]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}}}}
            (sequence_supervisor) lib/sequence_supervisor.ex:18: SequenceSupervisor.start/2
            (kernel) application_master.erl:273: :application_master.start_it_old/4
defmodule SequenceSupervisor do
  use Application

  # See http://elixir-lang.org/docs/stable/elixir/Application.html
  # for more information on OTP Applications
  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    children = [
      # Define workers and child supervisors to be supervised
      # worker(SequenceSupervisor.Worker, [arg1, arg2, arg3]),
      worker(SequenceSupervisor.Server, [123])
    ]

    # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: SequenceSupervisor.Supervisor]
    {:ok, _pid} = Supervisor.start_link(children, opts)
  end
end
目录树

sequence_supervisor.ex

mix文件mix.exs


如果查看提供的堆栈跟踪,则有一个段:

{:undef, [{Sequence.Server, :start_link, '{', []
这意味着有东西试图调用Sequence.Server模块上的start_link函数,但它是一个未定义的函数

根据目录树判断,不仅Sequence.Server的start_link函数未定义,而且Sequence.Server模块本身似乎也未定义。这可能是因为您还没有为它编写代码


它的代码可以在上找到。

如果您查看提供的堆栈跟踪,则有一段:

{:undef, [{Sequence.Server, :start_link, '{', []
这意味着有东西试图调用Sequence.Server模块上的start_link函数,但它是一个未定义的函数

根据目录树判断,不仅Sequence.Server的start_link函数未定义,而且Sequence.Server模块本身似乎也未定义。这可能是因为您还没有为它编写代码

其代码可在上找到

defmodule SequenceSupervisor.Mixfile do
  use Mix.Project

  def project do
    [app: :sequence_supervisor,
     version: "0.0.1",
     elixir: "~> 1.1",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps]
  end

  # Configuration for the OTP application
  #
  # Type "mix help compile.app" for more information
  def application do
    [applications: [:logger],
     mod: {SequenceSupervisor, []}]
  end

  # Dependencies can be Hex packages:
  #
  #   {:mydep, "~> 0.3.0"}
  #
  # Or git/path repositories:
  #
  #   {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
  #
  # Type "mix help deps" for more examples and options
  defp deps do
    []
  end
end
{:undef, [{Sequence.Server, :start_link, '{', []