[PD1] Error handling project-wide

This commit is contained in:
Afonso Franco 2024-04-28 22:02:13 +01:00
parent f5b3726673
commit b918211736
Signed by: afonso
SSH key fingerprint: SHA256:aiLbdlPwXKJS5wMnghdtod0SPy8imZjlVvCyUX9DJNk
13 changed files with 364 additions and 245 deletions

View file

@ -2,7 +2,6 @@ package networking
import (
"crypto/tls"
"log"
)
@ -14,11 +13,11 @@ type Client[T any] struct {
Connection Connection[T]
}
func NewClient[T any](clientTLSConfigProvider ClientTLSConfigProvider) Client[T] {
func NewClient[T any](clientTLSConfigProvider ClientTLSConfigProvider) (Client[T],error) {
dialConn, err := tls.Dial("tcp", "localhost:8080", clientTLSConfigProvider.GetClientTLSConfig())
if err != nil {
log.Panicln("Server connection error:\n",err)
return Client[T]{},err
}
conn := NewConnection[T](dialConn)
return Client[T]{Connection: conn}
return Client[T]{Connection: conn},nil
}