Git Product home page Git Product logo

exc_error's People

Contributors

miros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

a-sharapov

exc_error's Issues

assert_exc_error hangs if the message function implementation uses string interpolation without inspect

When I define MyError message function with string interpolation without inspect

  ExcError.define MyError, [:str] do
    @impl true
    def message(str), do: "#{str} without inspect"
  end

this test hangs

  describe "MyError" do
    test "test interpolation" do
      error = {:error, %MyError{str: "foo"}}
      assert_exc_error({:error, %MyError{}} = error)
    end
  end
  1) test MyError test interpolation (MyTest)
     test/my_test.exs:15
     ** (ExUnit.TimeoutError) test timed out after 60000ms. You can change the timeout:
     
       1. per test by setting "@tag timeout: x" (accepts :infinity)
       2. per test module by setting "@moduletag timeout: x" (accepts :infinity)
       3. globally via "ExUnit.start(timeout: x)" configuration
       4. by running "mix test --timeout x" which sets timeout
       5. or by running "mix test --trace" which sets timeout to infinity
          (useful when using IEx.pry/0)
     
     where "x" is the timeout given as integer in milliseconds (defaults to 60_000).
     
     code: assert_exc_error({:error, %MyError{}} = error)
     stacktrace:
       (elixir 1.11.2) lib/string/chars.ex:3: String.Chars.impl_for!/1
       (elixir 1.11.2) lib/string/chars.ex:22: String.Chars.to_string/1
       (data_io 0.1.0) lib/my_module.ex:9: MyError.message/1
       test/my_test.exs:17: (test)
       (ex_unit 1.11.2) lib/ex_unit/runner.ex:391: ExUnit.Runner.exec_test/1
       (stdlib 3.13) timer.erl:166: :timer.tc/1
       (ex_unit 1.11.2) lib/ex_unit/runner.ex:342: anonymous fn/4 in ExUnit.Runner.spawn_test_monitor/4

When I use inspect in string interpolation everything is OK

  ExcError.define MyError, [:str] do
    @impl true
    def message(str), do: "#{inspect(str)} with inspect"
  end

ExcError doesn't define own type

The trouble with dialyzer and ExcError, I'm specifying possible error for my function and launch mix dialyzer

module example below:

defmodule Test do
  @moduledoc """
  Documentation for Test.
  """
  require ExcError

  ExcError.define SomeTerribleError

  @spec hello :: SomeTerribleError.t()
  def hello do
    %SomeTerribleError{message: "It's you :)"}
  end
end

current result:

$ mix dialyzer
...
:0: Unknown type 'Elixir.Test.SomeTerribleError':t/0

expected result:

$ mix dialyzer
...
Well done, great job! There are no errors and warnings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.