about summary refs log tree commit diff stats
path: root/src/ips
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-10 19:05:38 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-10 19:05:38 +0100
commit1e858c874804444bc4b95b6e89eb96a0deb8473c (patch)
tree3151b498e19c6d6eed3d90827483eb270314f3da /src/ips
parentd963385cd9fd77f0a950c5b92be7774bbf76d661 (diff)
downloadchawan-1e858c874804444bc4b95b6e89eb96a0deb8473c.tar.gz
Add support for the encoding standard, fix parseLegacyColor
Also, fix a bug in the
Diffstat (limited to 'src/ips')
-rw-r--r--src/ips/socketstream.nim10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ips/socketstream.nim b/src/ips/socketstream.nim
index 1fe99c3b..c0abf07f 100644
--- a/src/ips/socketstream.nim
+++ b/src/ips/socketstream.nim
@@ -6,6 +6,7 @@ import streams
 when defined(posix):
   import posix
 
+import io/posixstream
 import ips/serversocket
 
 type SocketStream* = ref object of Stream
@@ -17,7 +18,14 @@ proc sockReadData(s: Stream, buffer: pointer, len: int): int =
   let s = SocketStream(s)
   result = s.source.recv(buffer, len)
   if result < 0:
-    raise newException(IOError, "Failed to read data (code " & $osLastError() & ")")
+    if errno == EAGAIN:
+      raise newException(ErrorAgain, "")
+    case errno
+    of EWOULDBLOCK: raise newException(ErrorWouldBlock, "")
+    of EBADF: raise newException(ErrorBadFD, "")
+    of EFAULT: raise newException(ErrorFault, "")
+    of EINVAL: raise newException(ErrorInvalid, "")
+    else: raise newException(IOError, $strerror(errno))
   elif result == 0:
     s.isend = true