Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CollectionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ object CollectionManager {
return count
}

@Throws(Exception::class)
fun fullName(
collectionName: String,
scopeName: String,
databaseName: String
): String {
val col = this.getCollection(collectionName, scopeName, databaseName)
return col?.fullName ?: throw Exception("Collection not found: $collectionName in scope: $scopeName")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better error handling and debugging, consider throwing a more specific exception and providing a more detailed error message.

  • Exception Type: Instead of the generic Exception, throwing a more specific one like IllegalArgumentException or NoSuchElementException allows callers to handle this specific error case more cleanly.
  • Error Message: The current error message is missing the databaseName, which is crucial for identifying which database the collection was not found in. Including it will make debugging easier.
Suggested change
return col?.fullName ?: throw Exception("Collection not found: $collectionName in scope: $scopeName")
return col?.fullName ?: throw IllegalArgumentException("Collection '$collectionName' not found in scope '$scopeName' of database '$databaseName'")

}

@Throws(Exception::class)
fun getBlobContent(key: String,
documentId: String,
Expand Down