Skip to content

Commit

Permalink
Fix Elixir 1.17 type error
Browse files Browse the repository at this point in the history
```
    warning: unknown key .message in expression:

        maybe_json_parser_exception.message

    where "maybe_json_parser_exception" was given the type:

        # type: %{..., __exception__: true, __struct__: atom()}
        # from: lib/slipstream/serializer/phoenix_socket_v2_serializer.ex:65
        rescue maybe_json_parser_exception ->

    hint: when you rescue without specifying exception names, the variable is assigned a type of a struct but all of its fields are unknown. If you are trying to access an exception's :message key, either specify the exception names or use `Exception.message/1`.

    typing violation found at:
    │
 68 │           [message: maybe_json_parser_exception.message],
    │                                                 ~~~~~~~
    │
    └─ lib/slipstream/serializer/phoenix_socket_v2_serializer.ex:68:49: Slipstream.Serializer.PhoenixSocketV2Serializer.encode!/2
```
  • Loading branch information
fhunleth committed Sep 24, 2024
1 parent 2b1acf8 commit f4d7476
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/slipstream/serializer/phoenix_socket_v2_serializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ defmodule Slipstream.Serializer.PhoenixSocketV2Serializer do
maybe_json_parser_exception ->
reraise(
Serializer.EncodeError,
[message: maybe_json_parser_exception.message],
[message: Exception.message(maybe_json_parser_exception)],
__STACKTRACE__
)

Expand Down

0 comments on commit f4d7476

Please sign in to comment.