Skip to content

Commit

Permalink
Apply an undefined_function format suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottming committed Jul 20, 2023
1 parent b1436e5 commit 30e3e82
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions apps/remote_control/lib/lexical/remote_control/build/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,11 @@ defmodule Lexical.RemoteControl.Build.Error do
%Result{result | message: format_message(result.message)}
end

@undefined_function_pattern ~r/ \(expected ([A-Za-z0-9_\.]*) to define such a function or for it to be imported, but.*/

defp format_message("undefined" <> _ = message) do
# All undefined messages explain the *same* thing inside the parentheses,
# like: `undefined function print/1 (expected Foo to define such a function or for it to be imported,
# but none are available)`
# that makes no sense and just creates noise.
# So we can remove the things in parentheses

message
|> String.split(" (")
|> List.first()
# All undefined function messages explain the *same* thing inside the parentheses
String.replace(message, @undefined_function_pattern, "")
end

defp format_message(message) when is_binary(message) do
Expand Down

0 comments on commit 30e3e82

Please sign in to comment.