Skip to content

Commit e2d89be

Browse files
committed
Add error messages for spec errors form ElixirChecker module
1 parent 06f3d83 commit e2d89be

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/gradient/elixir_fmt.ex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,33 @@ defmodule Gradient.ElixirFmt do
6969
format_expr_type_error(expression, actual_type, expected_type, opts)
7070
end
7171

72+
def format_type_error(
73+
{:spec_error, :wrong_spec_name, anno, name, arity},
74+
opts
75+
) do
76+
:io_lib.format(
77+
"~sThe spec ~p/~p~s doesn't match the function name/arity~n",
78+
[
79+
format_location(anno, :brief, opts),
80+
name,
81+
arity,
82+
format_location(anno, :verbose, opts)
83+
]
84+
)
85+
end
86+
87+
def format_type_error({:spec_error, :spec_after_spec, anno, name, arity}, opts) do
88+
:io_lib.format(
89+
"~sThe spec ~p/~p~s follows another spec when only one spec per function clause is allowed~n",
90+
[
91+
format_location(anno, :brief, opts),
92+
name,
93+
arity,
94+
format_location(anno, :verbose, opts)
95+
]
96+
)
97+
end
98+
7299
def format_type_error({:call_undef, anno, module, func, arity}, opts) do
73100
:io_lib.format(
74101
"~sCall to undefined function ~s~p/~p~s~n",

0 commit comments

Comments
 (0)