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
各レイヤーからのエラーについて考える
Search
yoshiyoshifujii
October 21, 2017
Programming
3
3.5k
各レイヤーからのエラーについて考える
関西Javaエンジニアの会(関ジャバ) '17 10月度
https://kanjava.connpass.com/event/68169/
yoshiyoshifujii
October 21, 2017
Tweet
Share
More Decks by yoshiyoshifujii
See All by yoshiyoshifujii
プロダクトオーナーの視座から見た信頼性とオブザーバビリティ / Reliability and Observability from the Perspective of a Product Owner
yoshiyoshifujii
1
1.4k
プロダクトオーナーがFour Keys + 信頼性に思うところ / Product Owners Think of Four Keys + Reliability
yoshiyoshifujii
0
480
Recapping Chatwork Scala Journey - ScalaMatsuri2023
yoshiyoshifujii
0
2.6k
ここ数ヶ月でAkkaを勉強した方法について紹介 / I have studied Akka in the past few months
yoshiyoshifujii
1
260
コードをどまんなかに据えたモデリング-Scala版 / Modeling with code in the middle-Scala version
yoshiyoshifujii
0
120
Chatworkのドメインをモデリングした / Modeling Chatwork domain
yoshiyoshifujii
0
810
サマーインターンシップ2019で学生とDDDなScala開発に取り組んだ / Working on DDD and Scala development with students at Summer Internship 2019
yoshiyoshifujii
2
4k
Clean Architecture in Practice @ScalaMatsuri2019
yoshiyoshifujii
9
4k
実践 Clean Architecture
yoshiyoshifujii
13
10k
Other Decks in Programming
See All in Programming
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
450
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
450
情報漏洩させないための設計
kubotak
2
260
快速入門可觀測性
blueswen
0
370
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
260
testcontainers のススメ
sgash708
1
120
Haze - Real time background blurring
chrisbanes
1
510
MCP with Cloudflare Workers
yusukebe
2
220
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
390
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
450
return文におけるstd::moveについて
onihusube
1
1.1k
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
A better future with KSS
kneath
238
17k
Practical Orchestrator
shlominoach
186
10k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Fireside Chat
paigeccino
34
3.1k
Typedesign – Prime Four
hannesfritz
40
2.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Transcript
֤ϨΠϠʔ͔Βͷ Τϥʔʹ͍ͭͯߟ͑Δ 4BU !ZPTIJZPTIJGVKJJ
͜Μʹͪ w:PTIJUBLB'VKJJ !ZPTIJZPTIJGVKJJ w4PGUXBSF&OHJOFFS w4DBMB+BWB1ZUIPO 5ZQFTDSJQU w4DBMBؔ4VNNJU4UB⒎
ձεϙϯαʔͬͯ·͢
ି͠ग़͠Ͱ͖Δ෦ w ηϛφʔϗʔϧ ໊ w ձٞࣨ ໊͔Β໊ w
ΧϑΣεϖʔε ໊ w ϏΞόογϡͳͲͷ࠙ձ։࠵ՄೳͰ͢ʂ
ࠓͷ͓ͷલఏ w3&45"1*ͷαʔόαΠυ ը໘ؚΈ·ͤΜ w4DBMB w࣮ફͯ͠Έͨ݁ՌΛཧ w.BZFSຊಡΜͰ·ͤΜ
Τϥʔͷྨ wϢʔβʔͷૢ࡞ΛىҼͱ͢ΔΤϥʔ wγεςϜͷোΛىҼͱ͢ΔΤϥʔ
Ϣʔβʔͷૢ࡞ΛىҼͱ͢Δ wܖʹҧ͢ΔΑ͏ͳૢ࡞ wඞਢɺ͞ɺܕɺॏෳͳͲ wجຊతʹը໘ଆͰ֬ೝ͢Δ wࠓճɺ"1*Λݺͼग़͢͜ͱΛఆ wෆਖ਼ΞΫηε
γεςϜͷোΛىҼͱ͢Δ w*0ྫ֎ w/FUXPSLɺ4ZTUFN%PXO wόά w͵ΔΆ
)551εςʔλείʔυ wϢʔβʔͷૢ࡞൪ wγεςϜͷো൪
υϝΠϯۦಈઃܭ
-BZFSFE"SDIJUFDUVSF w6TFS*OUFSGBDF w"QQMJDBUJPO w%PNBJO w*OGSBTUSVDUVSF &WBOT &SJD%PNBJO%SJWFO%FTJHO5BDLMJOH$PNQMFYJUZJOUIF)FBSUPG4PGUXBSF ,JOEMFͷҐஔ/P 1FBSTPO&EVDBUJPO,JOEMF൛
ࡾ υϝΠϯϞσϧ wϓϨθϯςʔγϣϯ wΞϓϦέʔγϣϯ wσʔλιʔε wυϝΠϯϞσϧ ૿ాږݱͰཱͭγεςϜઃܭͷݪଇʙมߋΛָͰ҆શʹ͢ΔΦϒδΣΫτࢦͷ࣮ફٕ๏ ,JOEMFͷҐஔ/P גࣜձٕࣾज़ධࣾ,JOEMF൛
ΦχΦϯΞʔΩςΫνϟ wΠϯλʔϑΣʔε wΞϓϦέʔγϣϯ wυϝΠϯ wΠϯϑϥετϥΫνϟ IUUQTTQFBLFSEFDLDPNDSPTTSPBETDBMBPOEEE TMJEF
ΠϯϑϥετϥΫνϟ Πϯϑϥ αʔϏε υϝΠϯ ϨΠϠʔͰѻ͏Τϥʔ ΠϯλʔϑΣʔε ΞϓϦέʔγϣϯ ϑΝΫτϦ ΤϯςΟςΟ υϝΠϯ
αʔϏε ϦϙδτϦ ΠϕϯτύϒϦ ογϟ ϦϙδτϦ࣮ Πϕϯτ ύϒϦογϟ࣮ +BWBϥΠϒϥϦ +%#$υϥΠό ྫ֎ ϦϙδτϦ Τϥʔ ΞϓϦέʔγ ϣϯΤϥʔ υϝΠϯ Τϥʔ ࢀߟIUUQTTQFBLFSEFDLDPNDSPTTSPBETDBMBPOEEE TMJEF 5SZ\ʜ^Ͱғͬͯྫ֎Λ 5SZܕʹม 5SZ
υϝΠϯ
υϝΠϯͷΤϥʔ wܖҧ wඞਢ wܕνΣοΫ w͞ɺ͔͞ wॏෳ w%PNBJO&SSPSܕ
ϦϙδτϦυϝΠϯͱಉ͡ wυϝΠϯʹϦϙδτϦΛఆٛ͢Δ wυϝΠϯͷΤϥʔܕͱಉ͡ʹ͢Δ͔
ϦϙδτϦͷΛߟ͑Δ wυϝΠϯͷӬଓԽ w࠶ੜ w*0ྫ֎ΛΑ͘ѻ͍ͦ͏
ϦϙδτϦͰҙ֎ͱߟྀ͖͢͜ͱ wָ؍ഉଞ 0QUJNJTUJD-PDLJOH w/PU'PVOE 0QUJPOPS'BJMVSF w͜ΕΒΛܕͰද໌ͨ͘͠ͳΔ
ϑΝΫτϦυϝΠϯͱಉ͡ wϑΝΫτϦυϝΠϯΛੜ͢Δ wυϝΠϯͷੜ࣌ʹܖҧΛ֬ೝ͢ Δ wυϝΠϯͷΤϥʔͱಉ͡Ͱྑ͍
ΠϕϯτύϒϦογϟ wυϝΠϯΠϕϯτͷύϒϦογϡ wܖҧͷݕূऴΘͬͨঢ়ଶ w*0ྫ֎ͷΈΛߟྀͰྑ͍
υϝΠϯαʔϏε wυϝΠϯͷϏδωεϧʔϧΛѻ͏ wܖҧΛѻ͏ wϦϙδτϦѻΘͳ͍
υϝΠϯͷΤϥʔܕ w%PNBJO&SSPSܕ w3FQPTJUPSZ&SSPSܕ wྫ֎ TDBMBVUJM5SZ
Πϯϑϥ ετϥΫνϟ
ΠϯϑϥετϥΫνϟ Πϯϑϥ αʔϏε υϝΠϯ ϨΠϠʔͰѻ͏Τϥʔ ΠϯλʔϑΣʔε ΞϓϦέʔγϣϯ ϑΝΫτϦ ΤϯςΟςΟ υϝΠϯ
αʔϏε ϦϙδτϦ ΠϕϯτύϒϦ ογϟ ϦϙδτϦ࣮ Πϕϯτ ύϒϦογϟ࣮ +BWBϥΠϒϥϦ +%#$υϥΠό ྫ֎ ϦϙδτϦ Τϥʔ ΞϓϦέʔγ ϣϯΤϥʔ υϝΠϯ Τϥʔ ࢀߟIUUQTTQFBLFSEFDLDPNDSPTTSPBETDBMBPOEEE TMJEF 5SZ\ʜ^Ͱғͬͯྫ֎Λ 5SZܕʹม 5SZ
ϦϙδτϦ࣮ wυϝΠϯͷఆٛʹै͏ w3%#ɺ,74ɺ"84 ,JOFTJTɺ424ɺ4 w+BWB-JCSBSZ wྫ֎ΛUSZDBUDIͯ͠$POWFSU w-JCSBSZͷґଘܕด͡ࠐΊΔ
ΠϕϯτύϒϦογϟ࣮ wྫ֎Λͦͷ··ѻ͏ wಛผʹܕΛఆٛͯ͠ѻΘͳ͍
ΠϯϑϥετϥΫνϟαʔϏε wυϝΠϯͰදݱ͢Δඞཁͷͳ͍Πϯϑϥ ૢ࡞ wϑΝΠϧΞοϓϩʔυΛςϯϙϥϦʔʹ Ұ࣌อଘ w҉߸Խ෮߸
ΠϯϑϥετϥΫνϟͷΤϥʔܕ w3FQPTJUPSZ&SSPSܕ wྫ֎
ΞϓϦέʔγϣϯ
ΠϯϑϥετϥΫνϟ Πϯϑϥ αʔϏε υϝΠϯ ϨΠϠʔͰѻ͏Τϥʔ ΠϯλʔϑΣʔε ΞϓϦέʔγϣϯ ϑΝΫτϦ ΤϯςΟςΟ υϝΠϯ
αʔϏε ϦϙδτϦ ΠϕϯτύϒϦ ογϟ ϦϙδτϦ࣮ Πϕϯτ ύϒϦογϟ࣮ +BWBϥΠϒϥϦ +%#$υϥΠό ྫ֎ ϦϙδτϦ Τϥʔ ΞϓϦέʔγ ϣϯΤϥʔ υϝΠϯ Τϥʔ ࢀߟIUUQTTQFBLFSEFDLDPNDSPTTSPBETDBMBPOEEE TMJEF 5SZ\ʜ^Ͱғͬͯྫ֎Λ 5SZܕʹม 5SZ
ΞϓϦέʔγϣϯαʔϏε wϢʔεέʔεهड़Λॻ͘Α͏ʹ wϢʔεέʔεͱͯ͠ΤϥʔΛද໌͢Δ w%PNBJO&SSPS 3FQPTJUPSZ&SSPS ྫ֎ Λ$POWFSU
ΞϓϦέʔγϣϯΤϥʔ wϢʔεέʔεͱͯ͠ͷ Τϥʔද໌ w/PU'PVOE w#BE3FRVFTU w4ZTUFN&SSPS
$POWFSUΛཧ w%PNBJO&SSPS"QQMJDBUJPO&SSPS w3FQPTJUPSZ&SSPS"QQMJDBUJPO&SSPS wྫ֎"QQMJDBUJPO&SSPS
$POWFSUΛཧ wΤϥʔܕΛද໌ͨ͜͠ͱͰ$POWFSU͕ େม wશͯ"QQMJDBUJPO&SSPSʹ͢Δ w$POWFSUΛ͏·࣮͘͠ͳ͍ͱਏ͍
object ApplicationErrorConverters { implicit class DomainError2ApplicationError[E](val e: Either[DomainError, E]) extends
AnyVal { def toApplicationError: Either[ApplicationError, E] = e.fold( l => Left(BadRequestError(Option(l.message))), Right(_) ) } }
object ApplicationErrorConverters { implicit class RepositoryError2ApplicationError[E](val e: Either[RepositoryError, E]) extends
AnyVal { def toApplicationError: Either[ApplicationError, E] = e.fold( { case _: RepositoryOptimisticError => Left(ConflictError) case _: RepositoryNotFoundError => Left(NoContentsError) case _: RepositoryAlreadyExistsError => Left(BadRequestError(Some("already_exists"))) case RepositorySystemError(t) => Left(InternalServerError(t)) }, Right(_) ) } }
object ApplicationErrorConverters { implicit class Try2ApplicationError[E](val e: Try[E]) extends AnyVal
{ def toApplicationError: Either[ApplicationError, E] = e.fold( e => Left(InternalServerError(e)), Right(_) ) } }
ΠϯλʔϑΣʔε
ΠϯϑϥετϥΫνϟ Πϯϑϥ αʔϏε υϝΠϯ ϨΠϠʔͰѻ͏Τϥʔ ΠϯλʔϑΣʔε ΞϓϦέʔγϣϯ ϑΝΫτϦ ΤϯςΟςΟ υϝΠϯ
αʔϏε ϦϙδτϦ ΠϕϯτύϒϦ ογϟ ϦϙδτϦ࣮ Πϕϯτ ύϒϦογϟ࣮ +BWBϥΠϒϥϦ +%#$υϥΠό ྫ֎ ϦϙδτϦ Τϥʔ ΞϓϦέʔγ ϣϯΤϥʔ υϝΠϯ Τϥʔ ࢀߟIUUQTTQFBLFSEFDLDPNDSPTTSPBETDBMBPOEEE TMJEF 5SZ\ʜ^Ͱғͬͯྫ֎Λ 5SZܕʹม 5SZ
"QQMJDBUJPO&SSPSΛ$POWFSU w)551εςʔλεʹม w/PU'PVOE w#BE3FRVFTU w*OUFSOBM4FSWFS&SSPS
)551Ҏ֎ͷΠϯλϑΣʔε w4VCTDSJCFS w3FDJFWFS w$PNNBOE-JOF*OUFSGBDF
4VCTDSJCFS w/PU'PVOE4LJQ w#BE3FRVFTU4LJQ w*OUFSOBM4FSWFS&SSPS3FUSZ
ΠϯλϑΣʔεʹґଘ͢Δ wΠϯλϑΣʔε͕)551ͳΒ)551ʹ w4VC3FDJFWFSͳΒ4LJQ͔3FUSZ wӬԕʹղফ͞Εͳ͍3FUSZΛ࡞ͬͯॲ ཧΛԆͤ͞ͳ͍Α͏அ͕ཁΔ
'JO