Skip to content

Commit b3b1420

Browse files
committed
Normalize exception handling in diagnostics
1 parent ffa3ef1 commit b3b1420

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

lib/elixir/lib/code.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ defmodule Code do
212212
required(:position) => position(),
213213
required(:stacktrace) => Exception.stacktrace(),
214214
required(:span) => {line :: pos_integer(), column :: pos_integer()} | nil,
215-
optional(:exception) => Exception.t() | nil,
215+
optional(:details) => term(),
216216
optional(any()) => any()
217217
}
218218

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,10 @@ defmodule Kernel.ParallelCompiler do
901901
severity: :error,
902902
stacktrace: stack,
903903
span: span,
904-
exception: get_exception(reason)
904+
details: {kind, reason}
905905
}
906906
end
907907

908-
defp get_exception(exception) when is_exception(exception), do: exception
909-
defp get_exception(_reason), do: nil
910-
911908
defp get_line_span(
912909
_file,
913910
%{line: line, column: column, end_line: end_line, end_column: end_column},

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ defmodule Mix.Compilers.Elixir do
785785
compiler_name: "Elixir",
786786
stacktrace: stacktrace,
787787
span: span,
788-
details: Map.get(diagnostic, :exception, nil)
788+
details: Map.get(diagnostic, :details, nil)
789789
}
790790
end
791791

lib/mix/lib/mix/task.compiler.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ defmodule Mix.Task.Compiler do
4747
message: IO.chardata(),
4848
position: Code.position(),
4949
compiler_name: String.t(),
50-
details: Exception.t() | any,
50+
details: term(),
5151
stacktrace: Exception.stacktrace(),
5252
span: {line :: pos_integer(), column :: pos_integer()} | nil
5353
}

lib/mix/test/mix/tasks/compile_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ defmodule Mix.Tasks.CompileTest do
183183
position: {2, 20},
184184
message: "** (SyntaxError) invalid syntax found on lib/a.ex:2:" <> _,
185185
compiler_name: "Elixir",
186-
details: %SyntaxError{}
186+
details: {:error, %SyntaxError{}}
187187
} = diagnostic
188188
end)
189189
end)

0 commit comments

Comments
 (0)