Web Application Good Error Message (and Bad Error Message)

672ee2598bea695496f11022a9a9c4c8?s=47 moznion
July 01, 2017

Web Application Good Error Message (and Bad Error Message)

A slide of YAPC::Fukuoka Hakata 2017

672ee2598bea695496f11022a9a9c4c8?s=128

moznion

July 01, 2017
Tweet

Transcript

  1. 22.

    - ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻

    - ϝτϦΫεతʹ΋ - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ
  2. 23.

    - ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻

    - ϩάɾϝτϦΫεత - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ
  3. 24.

    - ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻

    - ϩάɾϝτϦΫεత - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ
  4. 25.

    - ୹ण໋ - ͦͷ৔Ͱͷରॲʹར༻ - ଈԠ - ௕ण໋ - ࠜຊతͳղܾʹར༻

    - ϩάɾϝτϦΫεత - ͋ͱͰݕࡧͰ͖Δ Error MessageͷϥΠϑαΠΫϧ Errorͷྲྀ଎Λ ؂ࢹͯ͠alertͱ͔
  5. 31.

    ରॲ͢ΔͨΊͷError Message - ͦͷ৔Ͱൃੜ͍ͯ͠Δ໰୊Λଧ౗͢Δ - e.g. ʮωοτϫʔΫྑ͍ͱ͜ΖͰࢼͯ͠ʂʯ - ղܾʹܨ͕Δ৔߹΋͋Δ -

    ར༻ऀ͕ετϨεແ͘ιϑτ΢ΣΞΛར༻͢Δ ͨΊͷखॿ͚ => Ϣʔβମݧ - ։ൃऀɾར༻ऀ૒ํ޲͚ - ୹໋ϥΠϑαΠΫϧ
  6. 34.

    ѱ͍Error Messageͱ͸ - ·ͬͨ͘ঢ়گ͕Θ͔Βͳ͍ - e.g. "Something wrong!" - Ͳ͏͢Ε͹ྑ͍ͱ͍͏ͷͩ……

    - e.g. "Invalid parameter", "Query is too big" - ৘ใྔ͕ଟ͗͢Δ - ੌ·͍͡ྔͷstack trace͕ग़Δͱ͔…… - ΫϦεϚεπϦʔݱ৅
  7. 38.
  8. 40.

    HTTP Status Code - 1xx, 2xx, 3xx, 4xx, 5xx -

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

    - Over HTTPͳrequestͷerror response - e.g. 
 {
 "code": 1212,


    "error": "Not permitted operation"
 } API Response
  10. 47.

    Exit status - `$ echo $?` - 0ͩͬͨΒ੒ޭ - ͦͷଞ͸ࣦഊ

    (ਈ࢜ڠఆ) - http://moznion.hatenadiary.com/ entry/2017/06/30/181433
  11. 48.

    ୯७ͳ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
  12. 49.

    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 'git@github.com: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.
  13. 50.
  14. 55.

    Q?

  15. 56.
  16. 59.

    Error Message຋༁ - "SQL Error" => "500 αʔϏεʹ໰୊͕ੜ͡ ͍ͯ·͢" -

    status 5963 => "૬खͷαʔό͕Ωϟύγ ςΟΦʔόͰࢮΜͰΔʂʂ" - status code͔Βঢ়گͷจݴʹى͜͢ͳͲ ͱ͍ͬͨ࣍ݩͷΞηϯγϣϯ΋ى͖͕ͪ
  17. 63.

    Q?