-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Tag<T>.values() method #15
Comments
これ fun <T: Any> Tag<T>.idResult: Result<Identifier>
get() = runCatching { (this as Tag.Identified<T>).id } |
ただなんでもかんでも |
失敗する可能性を型で表現するためにResultを使うのは良いことだと思いますよ |
This comment was marked as resolved.
This comment was marked as resolved.
Resultを使うか使わないか、全体を通して方針を統一しないと無秩序になるので、何かしらの統一はしたい
|
|
これちゃんと確認したんですけど、吐かれる可能性あるのは IllegalStateException みたいですね。例外潰してemptyList返すなら一応warnで例外をログに流すとかはした方が良いかもしれません |
こんな感じかな fun <T : Any> Tag<T>.safeValues(): List<T> = runCatching { values() }
.onFailure { e: Throwable -> HTLogger.log { logger: Logger -> logger.throwing(e) } }
.getOrDefault(emptyList()) |
実装次第では
Tag<T>.values()
を呼ぶと例外を吐かれる現状らぎマテで使ってるのはこれ
これを改善して
的なのをつくれないだろうか
The text was updated successfully, but these errors were encountered: