···1515 // --- POSTGRES RELATED ERRORS -----------------------------------------------
1616 /// When we can't establish a TCP connection to the server.
1717 ///
1818- PgCannotEstablishTcpConnection(host: String, port: Int, reason: mug.Error)
1818+ PgCannotEstablishTcpConnection(
1919+ host: String,
2020+ port: Int,
2121+ reason: mug.ConnectError,
2222+ )
19232024 /// When the server immediately closes the connection right after we try to
2125 /// connect using the given username and database.
···245249 // that is actually printed and we do not have to make any effort to add and
246250 // print new errors.
247251 let printable_error = case error {
248248- PgCannotEstablishTcpConnection(host:, port:, reason:) ->
252252+ PgCannotEstablishTcpConnection(host:, port:, reason:) -> {
253253+ let mug_error = case reason {
254254+ mug.ConnectFailedBoth(ipv4: error, ipv6: _)
255255+ | mug.ConnectFailedIpv4(ipv4: error)
256256+ | mug.ConnectFailedIpv6(ipv6: error) -> error
257257+ }
258258+249259 printable_error("Cannot establish TCP connection")
250250- |> add_paragraph(case reason {
260260+ |> add_paragraph(case mug_error {
251261 mug.Econnrefused ->
252262 "I couldn't connect to the database because "
253263 <> style_inline_code(host)
···280290" <> style_inline_code(host) <> " at port " <> int.to_string(port) <> ":
281291" <> string.inspect(reason)
282292 })
293293+ }
283294284295 PgInvalidUserDatabase(user:, database:) ->
285296 printable_error("Cannot connect")