Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The Pitfalls of Cancellation
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Masatoshi Kubode
December 22, 2020
Programming
1.9k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The Pitfalls of Cancellation
Masatoshi Kubode
December 22, 2020
More Decks by Masatoshi Kubode
See All by Masatoshi Kubode
AIチャットの改善から見えた、良いAI体験とは / What Constitutes a Good AI Experience: Insights from Improving AI Chat
kubode
0
150
3リポジトリーを2ヶ月でモノレポ化した話 / How I turned 3 repositories into a monorepo in 2 months
kubode
0
240
ウォンテッドリーの「ココロオドル」モバイル開発 / Wantedly's "kokoro odoru" mobile development
kubode
2
1.3k
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
730
技術を根付かせる / How to make technology take root
kubode
1
500
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
650
Google Play Consoleデベロッパー アカウントの確認 / Verifying your Play Console developer account
kubode
1
1.4k
Make your Android app into Multiplatform app
kubode
0
240
ウォンテッドリーにおけるモバイルアプリ開発 / iOSDC Japan 2024 Sponsor Session
kubode
1
1.5k
Other Decks in Programming
See All in Programming
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
8.7k
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.8k
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
830
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
140
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
150
1B+ /day規模のログを管理する技術
broadleaf
0
130
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
390
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
240
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
170
symfony/aiとlaravel/boost
77web
0
120
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
The browser strikes back
jonoalderson
0
1.4k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.7k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.6k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
630
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Believing is Seeing
oripsolob
1
170
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
How to train your dragon (web standard)
notwaldorf
97
6.7k
The agentic SEO stack - context over prompts
schlessera
0
840
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
310
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.9k
Transcript
©2020 Wantedly, Inc. The Pitfalls of Cancellation Presentation Subtitle 2020/12/22
Masatoshi Kubode https://unsplash.com/photos/J8sh37XZ8ww
©2020 Wantedly, Inc. ٱอग़խढ़ 8BOUFEMZ 8BOUFEMZ7JTJUͷ"OESPJEΞϓϦΛ։ൃ͍ͯ͠·͢ɻ ,PUMJO .BHJDUIF(BUIFSJOH UIJTUP4USJOH 5XJUUFS
!TXJ[@BSE (JU)VC !LVCPEF
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2020 Wantedly, Inc. $PSPVUJOFTͰى͖ͨΫϥογϡͷ
©2020 Wantedly, Inc. ͋ΔͷΫϥογϡϨϙʔτ
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2020 Wantedly, Inc.
©2020 Wantedly, Inc. ֘ίʔυ class FetchDiscoverPostsUseCaseImpl( private val discoverRepository: DiscoverRepository,
) : FetchDiscoverPostsUseCase { override suspend operator fun invoke(sectionId: DiscoverSectionId) { try { return discoverRepository.fetchDiscoverPosts(sectionId) } catch (@Suppress("TooGenericExceptionCaught") e: Throwable) { throw FetchDiscoverProjectsUseCase.Error( "Failed to fetch discover posts for section: $sectionId”, e ) } } } ←ίϐϖͰTypoͯ͠Δ Repositoryͷྫ֎Λϥοϓͯ͠ Rethrowͯ͠Δ͚ͩͳͷʹ ͳͥ?
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2020 Wantedly, Inc. 4UBDL5SBDFΛΑ͘ݟΔ
©2020 Wantedly, Inc. ͋ΔͷΫϥογϡϨϙʔτ JobCancellationException͕ݪҼ
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2020 Wantedly, Inc. +PC$BODFMMBUJPO&YDFQUJPOͱ
©2020 Wantedly, Inc. JobCancellationException https://atoulme.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job-cancellation-exception/index.html Job.cancel()͞Εͨͱ͖ʹ suspend͍ͯ͠Δ͔ؔΒThrow͞ΕΔ CoroutinesͷγεςϜతͳྫ֎
©2020 Wantedly, Inc. ֘ίʔυ class FetchDiscoverPostsUseCaseImpl( private val discoverRepository: DiscoverRepository,
) : FetchDiscoverPostsUseCase { override suspend operator fun invoke(sectionId: DiscoverSectionId) { try { return discoverRepository.fetchDiscoverPosts(sectionId) } catch (@Suppress("TooGenericExceptionCaught") e: Throwable) { throw FetchDiscoverProjectsUseCase.Error( "Failed to fetch discover posts for section: $sectionId”, e ) } } } ͭ·ΓɺCoroutinesͷγεςϜతͳྫ֎Λ ϥοϓͯ͠͠·͔ͬͨΒΫϥογϡͨ͠
©2020 Wantedly, Inc. JobCancellationExceptionৄղ ͱͱJavaͷฒྻॲཧAPIͰΘΕ͍ͯͨྫ֎
©2020 Wantedly, Inc. Javaͷੈք java.util.concurrent.Future#get() try { future.get(); } catch
(ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } CancellationExceptionRuntimeException ͳͷͰ໌ࣔతͳcatchෆཁ CancellationΛcatchͪ͠Ό͏͜ͱ͕ى͖ͮΒ͍
©2020 Wantedly, Inc. Kotlinͷੈք Kotlinʹݕࠪྫ֎͕ͳ͍ catch(Throwable)͕ͪ͠ CoroutinesͰࠓճͷΑ͏ͳʹܨ͕Γ͍͢ cancel()ͯ͠ͳ͍͔ͱ͍͏ςετ;ͭ͏ॻ͔ͳ͍͠ɺ ݱঢ়ϓϩάϥϚ͕ؾΛ͚ͭΔ͔͠ͳ͍ʁ
©2020 Wantedly, Inc. Ͳ͏͖͔͢ launch { try { codeThatCanThrowExceptions() //
// } catch (e: Throwable) { // } catch (e: Exception) { // } catch (e: RuntimeException) { // } catch (e: IllegalStateException) { // } catch (e: CancellationException) { } catch (e: SpecificException) { // throw MyException(e) } } // OR launch { try { codeThatCanThrowExceptions() } catch (e: Throwable) { throw e as? CancellationException ?: MyException(e) } }
©2020 Wantedly, Inc. w ,PUMJOʹݕࠪྫ֎͕ͳ͍ͷͰࡶʹ͕͕ͪͩ͠ɺ $PSPVUJOFTͰ5PP(FOFSJDͳDBUDIةݥ w DBUDI͔ͨͬͨ͠Β$BODFMMBUJPOSFUISPX w ͘͠$PSPVUJOF&YDFQUJPO)BOEMFSΛ͏
w -JOUແࢹ͠ͳ͍ ·ͱΊ
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2020 Wantedly, Inc.