From 946e0e2d438f1076ea009901b1a69cb49425865f Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Fri, 8 Aug 2025 16:43:42 +0200 Subject: change read to use exceptions instead of error strings --- src/main/kotlin/Connection.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/main/kotlin/Connection.kt') diff --git a/src/main/kotlin/Connection.kt b/src/main/kotlin/Connection.kt index cb93533..984b345 100644 --- a/src/main/kotlin/Connection.kt +++ b/src/main/kotlin/Connection.kt @@ -190,7 +190,7 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { TODO("Not yet implemented") } - override fun read(fid: UInt, offset: ULong, count: UInt): Pair> { + override fun read(fid: UInt, offset: ULong, count: UInt): Array { val omsg = OutMessage(NinePMessageType.TREAD, this.tagGen.generate(), listOf("fid", "offset", "count"), mapOf( "fid" to BigInteger(fid.toString()), @@ -202,16 +202,12 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { this.maxSize ) omsg.write(this.tl) - val checkErr = checkedInMessage(omsg.tag) - if (checkErr.first != null) { - return Pair(checkErr.first, emptyArray()) - } - val imsg = checkErr.second!! + val imsg = checkedInMessage(omsg.tag) imsg.applyField(InMessage.Field("count", InMessage.Field.Type.INTEGER, 4u)) val count = imsg.fieldsInt["count"]!!.toInt().toUInt() imsg.applyField(InMessage.Field("data", InMessage.Field.Type.RAW, count)) - return Pair(null, imsg.fieldsRaw["data"]!!) + return imsg.fieldsRaw["data"]!! } override fun write(fid: UInt, offset: ULong, count: UInt, data: Iterable): Pair { -- cgit v1.2.3