Slide 1

Slide 1 text

Web Application Good Error Message (and Bad Error Message) @moznion

Slide 2

Slide 2 text

@moznion

Slide 3

Slide 3 text

Error Message

Slide 4

Slide 4 text

Error Messageͱ͸? - Τϥʔ͕ى͖ͨ࣌ʹग़ͯ͘Δϝοηʔδ - (جຊతʹ) ਓ͕ؒಡΉ - ҟৗܥͷॲཧ - Τϥʔϝοηʔδ͕པΓ……

Slide 5

Slide 5 text

Example { "code": "500", "message": "Internal Server Error" }

Slide 6

Slide 6 text

Error Messageͷ༻్ - ঢ়گͷද໌ - τϥϒϧγϡʔςΟϯάͷख͕͔Γ - αʔϏεͷ݈߁౓ͷࢦඪ

Slide 7

Slide 7 text

Error MessageपΓͷ໰୊ - Ͳ͏ॻ͚͹ྑ͍ͷ͔͍·͍ͪ…… - ޙखʹճΓ͕ͪ…… - ίετ͕……

Slide 8

Slide 8 text

Error Messageͷಛੑ

Slide 9

Slide 9 text

Error Messageͷ࣍ݩ

Slide 10

Slide 10 text

Error Messageͷ࣍ݩ 1࣍ݩ: Τϥʔίʔυ (ࣝผࢠ) 2࣍ݩ: Τϥʔϝοηʔδ (ঢ়گ) 3࣍ݩ: ϦΧόϦɾ࠶ݱ৘ใ (ରॲɾղܾ)

Slide 11

Slide 11 text

Error Messageͷ࣍ݩ 1࣍ݩ: Τϥʔίʔυ (ࣝผࢠ) 2࣍ݩ: Τϥʔϝοηʔδ (ঢ়گ) 3࣍ݩ: ϦΧόϦɾ࠶ݱ৘ใ (ରॲɾղܾ) ଞͷΤϥʔͱͷ۠ผ

Slide 12

Slide 12 text

Error Messageͷ࣍ݩ 1࣍ݩ: Τϥʔίʔυ (ࣝผࢠ) 2࣍ݩ: Τϥʔϝοηʔδ (ঢ়گ) 3࣍ݩ: ϦΧόϦɾ࠶ݱ৘ใ (ରॲɾղܾ)

Slide 13

Slide 13 text

Error Messageͷ࣍ݩ 1࣍ݩ: Τϥʔίʔυ (ࣝผࢠ) 2࣍ݩ: Τϥʔϝοηʔδ (ঢ়گ) 3࣍ݩ: ϦΧόϦɾ࠶ݱ৘ใ (ରॲɾղܾ) Կ͕ى͖͍ͯΔ͔ͷఏࣔ

Slide 14

Slide 14 text

Error Messageͷ࣍ݩ 1࣍ݩ: Τϥʔίʔυ (ࣝผࢠ) 2࣍ݩ: Τϥʔϝοηʔδ (ঢ়گ) 3࣍ݩ: ϦΧόϦɾ࠶ݱ৘ใ (ରॲɾղܾ)

Slide 15

Slide 15 text

Error Messageͷ࣍ݩ 1࣍ݩ: Τϥʔίʔυ (ࣝผࢠ) 2࣍ݩ: Τϥʔϝοηʔδ (ঢ়گ) 3࣍ݩ: ϦΧόϦɾ࠶ݱ৘ใ (ରॲɾղܾ) ໰୊ରॲɾղܾͷख๏ͷఏࣔ

Slide 16

Slide 16 text

Error Messageͷํ޲ੑ

Slide 17

Slide 17 text

Error Messageͷํ޲ੑ - ͳͥग़͢ͷ͔ - ԿΛग़͢ͷ͔ (࣍ݩʹؔΘΔ) - ͍ͭग़͢ͷ͔ (ϩάϨϕϧ) - Ͳ͜ʹग़͢ͷ͔ (ϩάऩूɼUI)

Slide 18

Slide 18 text

Error Messageͷํ޲ੑ - ͳͥग़͢ͷ͔ - ԿΛग़͢ͷ͔ (࣍ݩʹؔΘΔ) - ͍ͭग़͢ͷ͔ (ϩάϨϕϧ) - Ͳ͜ʹग़͢ͷ͔ (ϩάऩूɼUI)

Slide 19

Slide 19 text

Error Messageͷํ޲ੑ - ͳͥग़͢ͷ͔ - ԿΛग़͢ͷ͔ (࣍ݩʹؔΘΔ) - ͍ͭग़͢ͷ͔ (Ϩϕϧɼྔ) - Ͳ͜ʹग़͢ͷ͔ (ϩάऩूɼUI)

Slide 20

Slide 20 text

Error Messageͷํ޲ੑ - ͳͥग़͢ͷ͔ - ԿΛग़͢ͷ͔ (࣍ݩʹؔΘΔ) - ͍ͭग़͢ͷ͔ (Ϩϕϧɼྔ) - Ͳ͜ʹ (୭ʹ) ग़͢ͷ͔ (ϩάऩूɼUI)

Slide 21

Slide 21 text

Error Messageͷ ϥΠϑαΠΫϧ

Slide 22

Slide 22 text

- ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻ - ϝτϦΫεతʹ΋ - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ

Slide 23

Slide 23 text

- ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻ - ϩάɾϝτϦΫεత - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ

Slide 24

Slide 24 text

- ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻ - ϩάɾϝτϦΫεత - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ

Slide 25

Slide 25 text

- ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻ - ϩάɾϝτϦΫεత - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ Errorͷྲྀ଎Λ ؂ࢹͯ͠alertͱ͔

Slide 26

Slide 26 text

Good Error Message

Slide 27

Slide 27 text

ྑ͍Error Messageͱ͸? - Կ͕ى͖͍ͯΔ͔෼͔Δ (ඞਢ) - ؆ܿͰ͋Δ͜ͱ (޷·͍͠) - ରॲखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ) - ղܾखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ)

Slide 28

Slide 28 text

ྑ͍Error Messageͱ͸? - Կ͕ى͖͍ͯΔ͔෼͔Δ (ඞਢ) - ؆ܿͰ͋Δ͜ͱ (޷·͍͠) - ରॲखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ) - ղܾखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ)

Slide 29

Slide 29 text

"ରॲ"ͱ"ղܾ"ͷҧ͍

Slide 30

Slide 30 text

ղܾ͢ΔͨΊͷError Message - ࠜຊతͳमਖ਼ͷॿ͚ʹͳΔϝοηʔδ - e.g. RDBMS͕ग़͢ϝοηʔδ - ։ൃऀ޲͚ - ௕໋ϥΠϑαΠΫϧ

Slide 31

Slide 31 text

ରॲ͢ΔͨΊͷError Message - ͦͷ৔Ͱൃੜ͍ͯ͠Δ໰୊Λଧ౗͢Δ - e.g. ʮωοτϫʔΫྑ͍ͱ͜ΖͰࢼͯ͠ʂʯ - ղܾʹܨ͕Δ৔߹΋͋Δ - ར༻ऀ͕ετϨεແ͘ιϑτ΢ΣΞΛར༻͢Δ ͨΊͷखॿ͚ => Ϣʔβମݧ - ։ൃऀɾར༻ऀ૒ํ޲͚ - ୹໋ϥΠϑαΠΫϧ

Slide 32

Slide 32 text

ྑ͍Error Messageͱ͸? - Կ͕ى͖͍ͯΔ͔෼͔Δ (ඞਢ) - ؆ܿͰ͋Δ͜ͱ (޷·͍͠) - ରॲखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ) - ղܾखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ)

Slide 33

Slide 33 text

Bad Error Message

Slide 34

Slide 34 text

ѱ͍Error Messageͱ͸ - ·ͬͨ͘ঢ়گ͕Θ͔Βͳ͍ - e.g. "Something wrong!" - Ͳ͏͢Ε͹ྑ͍ͱ͍͏ͷͩ…… - e.g. "Invalid parameter", "Query is too big" - ৘ใྔ͕ଟ͗͢Δ - ੌ·͍͡ྔͷstack trace͕ग़Δͱ͔…… - ΫϦεϚεπϦʔݱ৅

Slide 35

Slide 35 text

ਅͷѱ͍Error Message

Slide 36

Slide 36 text

ਅͷѱ͍Error Message Error Message͕ແ͍

Slide 37

Slide 37 text

ਅͷѱ͍Error Message Error Message͕ແ͍ ແ͍ΑΓ͸͋ͬͨํ͕ྑ͍

Slide 38

Slide 38 text

ࣄྫ

Slide 39

Slide 39 text

Client Side

Slide 40

Slide 40 text

HTTP Status Code - 1xx, 2xx, 3xx, 4xx, 5xx - ίʔυʹΑΔ1࣍ݩ৘ใ - (↑ͱ͍͏ͷ͸ਖ਼͘͠ͳ͍ɽHTTP Status Codeʹ͸ηϚϯςΟΫε͕͋Δ)

Slide 41

Slide 41 text

- Over HTTPͳrequestͷerror response - e.g. 
 {
 "code": 1212,
 "error": "Not permitted operation"
 } API Response

Slide 42

Slide 42 text

؅ཧը໘্ͷදࣔ - ؅ཧը໘ͷૢ࡞தʹΤϥʔ͕ى͖Δ - ओʹΦϖϨʔλͷਓ޲͚Έ͍ͨͳ৔߹

Slide 43

Slide 43 text

؅ཧը໘্ͷදࣔ - ؅ཧը໘ͷૢ࡞தʹΤϥʔ͕ى͖Δ - ओʹΦϖϨʔλͷਓ޲͚Έ͍ͨͳ৔߹

Slide 44

Slide 44 text

؅ཧը໘্ͷදࣔ - ؅ཧը໘ͷૢ࡞தʹΤϥʔ͕ى͖Δ - ओʹΦϖϨʔλͷਓ޲͚Έ͍ͨͳ৔߹ ଐਓੑͩ... (ٞ࿦͠·ͤΜ)

Slide 45

Slide 45 text

Facebook Graph API - APIͷΦʔϓϯϓϥοτϑΥʔϜ - fbtrace_idʹΑΔΤϥʔ৘ใͷఏࣔ& τϥοΩϯά

Slide 46

Slide 46 text

Server Side

Slide 47

Slide 47 text

Exit status - `$ echo $?` - 0ͩͬͨΒ੒ޭ - ͦͷଞ͸ࣦഊ (ਈ࢜ڠఆ) - http://moznion.hatenadiary.com/ entry/2017/06/30/181433

Slide 48

Slide 48 text

୯७ͳError Log [12:29:14] DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'XXXXXXXXXXXXXX' for key 'user' [for Statement "INSERT /* ./local/lib/perl5/ Try/Tiny.pm line 77 */ INTO user (id) VALUES (?)" with ParamValues: 0="XXXXXXXXXXXXXX"] at ./lib/MyApp/Infra/ UserRepository/.pm line 123

Slide 49

Slide 49 text

GitͷError Message $ git push origin test To github.com:moznion/sandbox.git ! [rejected] test -> test (non-fast-forward) error: failed to push some refs to '[email protected]:moznion/ sandbox.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Slide 50

Slide 50 text

·ͱΊ

Slide 51

Slide 51 text

ྑ͍Error Messageͱ͸? - Կ͕ى͖͍ͯΔ͔෼͔Δ (ඞਢ) - ؆ܿͰ͋Δ͜ͱ (޷·͍͠) - ରॲखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ) - ղܾखஈ͕ఏҊ͞Ε͍ͯΔ͜ͱ (࠷ߴ)

Slide 52

Slide 52 text

ྑ͍Error MessageΛॻ͘ʹ͸ - ͳΔ΂࣍͘ݩͷߴ͍৘ใΛࣔ͢ - ݟͨਓ͕ٽ͔ͳ͍Α͏ʹ - ໨తΛ໌֬ʹɼͳΔ΂͘؆ܿʹ - ୭͕ݟΔͷ͔ɼԿʹ࢖ΘΕΔͷ͔ - ͱ͸͍͑ग़͠ौΒͳ͍

Slide 53

Slide 53 text

ͱ͸͍͑ - ৗʹ࣍ݩͷߴ͍ΤϥʔϝοηʔδΛॻ͘ ͷ͸೉͍͠ - ίετͷ݉Ͷ߹͍ - ݁ہϏδωευϝΠϯΛॻ͔ͳ͍ͱ
 Ͳ͏͠Α͏΋ͳ͍ͷͰ……

Slide 54

Slide 54 text

ίετײͱ໨త - ৄࡉͳΤϥʔϝοηʔδ͕ग़͢ͱ
 ϖΠͰ͖Δ෦෼͸खް͘ॻ͘ - ͦ͏͡Όͳ͍ͱ͜Ζ͸ͦΕͳΓʹ
 (ͱ͸͍͑ঢ়گ͘Β͍͸ͪΌΜͱॻ͘) - ྟػԠมʹ΍͍ͬͯ͘

Slide 55

Slide 55 text

Q?

Slide 56

Slide 56 text

Misc

Slide 57

Slide 57 text

Error Message຋༁

Slide 58

Slide 58 text

Error Message຋༁ - ҃ΔΤϥʔΛʮड͚औΓଆʯʹ;͞Θ͍͠ ಺༰ʹม׵͢Δ - e.g. αʔό಺෦Ͱൃੜͨ͠ΤϥʔΛ
 Ϣʔβʹࣔ͢৔߹ - e.g. ଞͷαʔϏε͔Βड͚औͬͨ
 ΤϥʔΛࣗ෼ͷจ຺ʹม׵͢Δ৔߹

Slide 59

Slide 59 text

Error Message຋༁ - "SQL Error" => "500 αʔϏεʹ໰୊͕ੜ͡ ͍ͯ·͢" - status 5963 => "૬खͷαʔό͕Ωϟύγ ςΟΦʔόͰࢮΜͰΔʂʂ" - status code͔Βঢ়گͷจݴʹى͜͢ͳͲ ͱ͍ͬͨ࣍ݩͷΞηϯγϣϯ΋ى͖͕ͪ

Slide 60

Slide 60 text

Stack TraceΛ
 Client޲͚Error Message ʹಥͬࠐΉ

Slide 61

Slide 61 text

Client΁ͷError Messageͱͯ͠ Stack traceΛಥͬࠐΉ - ։ൃ࣌ͷςΫχοΫ (ςΫχοΫ?) - αʔό͕ྫ֎Λ্͛ͨ࣌ͷελοΫτϨʔ εΛbodyʹ٧Ίͯ500Λฦ͢

Slide 62

Slide 62 text

Client΁ͷError Messageͱͯ͠ Stack traceΛಥͬࠐΉ - Client։ൃऀʮͳΜ͔͓͔͍͠ΜͰ͚͢ ͲʙʯΈ͍ͨͳ࣌ʹελοΫτϨʔεΛ
 ͦͷ··౉ͯ͠΋Β͑ΔͷͰศར - ProductionͰdisableʹ͠๨ΕΔͱ͠͵

Slide 63

Slide 63 text

Q?