diff options
author | Edoardo La Greca | 2025-08-07 20:22:06 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-07 20:22:06 +0200 |
commit | e00d101020ac21088e57c85bf0076d350f16e94f (patch) | |
tree | 0ebf7218c594569b3cd2221f2bc9935227819eea /src/main | |
parent | d6dbe5de92b0a42f74f18d9d4a590517e27df807 (diff) |
change attach to use exceptions instead of error strings
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/Connection.kt | 9 | ||||
-rw-r--r-- | src/main/kotlin/ProtocolTranslator.kt | 5 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/main/kotlin/Connection.kt b/src/main/kotlin/Connection.kt index 5fabf83..659dd41 100644 --- a/src/main/kotlin/Connection.kt +++ b/src/main/kotlin/Connection.kt @@ -120,7 +120,7 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { val imsg = checkedInMessage(omsg.tag) } - override fun attach(fid: UInt, afid: UInt, uname: String, aname: String): String? { + override fun attach(fid: UInt, afid: UInt, uname: String, aname: String) { val omsg = OutMessage(NinePMessageType.TATTACH, this.tagGen.generate(), listOf("fid", "afid", "uname", "aname"), mapOf( "fid" to BigInteger(fid.toString()), @@ -134,16 +134,11 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { this.maxSize ) omsg.write(this.tl) - val checkErr = checkedInMessage(omsg.tag) - if (checkErr.first != null) { - return checkErr.first - } - val imsg = checkErr.second!! + val imsg = checkedInMessage(omsg.tag) imsg.applyField(InMessage.Field("qid", InMessage.Field.Type.RAW, 13u)) val qid = QID(imsg.fieldsRaw["qid"]!!.toList()) this.pathInfo.addPath(PathInfo.Path(aname.split("/"), fid, qid)) - return null } override fun walk(fid: UInt, newfid: UInt, wname: List<String>): String? { diff --git a/src/main/kotlin/ProtocolTranslator.kt b/src/main/kotlin/ProtocolTranslator.kt index eb13fc2..1b45252 100644 --- a/src/main/kotlin/ProtocolTranslator.kt +++ b/src/main/kotlin/ProtocolTranslator.kt @@ -55,9 +55,10 @@ interface ProtocolTranslator { * @param afid A FID previously established by an auth message. * @param uname A user identifier. * @param aname The desired file tree to access. - * @return a possible error. + * @throws except.InvalidMessageException if the received message is invalid. + * @throws except.RErrorException if the received message is an R-error message. */ - fun attach(fid: UInt, afid: UInt, uname: String, aname: String): String? + fun attach(fid: UInt, afid: UInt, uname: String, aname: String) /** * Descend a directory hierarchy. |