Unhappy Exception Handling

48a913a2e3bb5e68aae6f73079648e84?s=47 Junichi Ito
November 15, 2018

Unhappy Exception Handling

I talked at Ruby Conf 2018 lightning talks.

48a913a2e3bb5e68aae6f73079648e84?s=128

Junichi Ito

November 15, 2018
Tweet

Transcript

  1. 6/)"11:&9$&15*0/)"/%-*/( +VOJDIJ*UP

  2. 5IFCBTJDTZOUBYPGFYDFQUJPOIBOEMJOHJO3VCZ begin # Exception might happen a = 1 /

    0 rescue => e # Handle the exception # and the program continues puts "error: #{e.message}" end puts a Twitter @jnchito / GitHub JunichiIto
  3. *UJTWFSZTJNQMF CVU ➤ 4PNFQSPHSBNNFSTNJTVTFFYDFQUJPOIBOEMJOH ➤ 5IFZNJTVOEFSTUBOEl*GFYDFQUJPOIBQQFOT VTFASFTDVFA5IBU`TPLBZz ➤ 5IFZCFHJOXSJUJOHASFTDVFAFWFSZXIFSF ➤

    5IFZCFMJFWFl.ZQSPHSBNJTOPXSFMJBCMFz ➤/0! Twitter @jnchito / GitHub JunichiIto
  4. 40.&:&"34"(0 Twitter @jnchito / GitHub JunichiIto

  5. *IBEBUSPVCMFBUBQSFWJPVTKPC ➤ *KPJOFEBQSFWJPVTDPNQBOZBTBOJOIPVTFTPGUXBSFFOHJOFFS ➤ *CFDBNFUIFNBJOUBJOFSPGBOFYJTUJOHJOIPVTFXFCBQQMJDBUJPO ➤ *UXBTBHPPECPZCFDBVTFJUIBECFFOSVOOJOH1&3'&$5-:GPSZFBST ➤ 0OFEBZ *IBEBOPQQPSUVOJUZUPUBMLXJUIPOFPGUIFVTFST

    ➤ )FTIPXFENFIJTSFHVMBSPQFSBUJPO*XBTXBUDIJOHJU ➤ )FDMJDLFEUIFTBWFCVUUPO UIFO*TBXBEJBMPHl4ZTUFNFSSz ➤ l0I XIBU 8IBU`TUIJT z ➤ l8FTFFJUWFSZPGUFO4PXF`SFDMJDLJOHUIFTBWFCVUUPOBHBJOBOEBHBJOz Twitter @jnchito / GitHub JunichiIto
  6. None
  7. 5IFDPEFXBTMJLFUIJT OPU3BJMTBDUVBMMZ def update @post.update!(post_params) redirect_to @post rescue => e

    # Just display error code flash[:alert] = "System err: #{e.code}" render :edit end ➤ /FJUIFSOPUJpFE OPSMPHHFE8FOFWFSOPUJDFEFWFOJGBOFSSPSPDDVSSFE ➤ 6OGPSUVOBUFMZ UIFVTFSTIBEBQSPDFEVSF l*GZPVHFUUIJTFSSPS LFFQPOSFUSZz ➤ 5IFSPPUDBVTF%FBEMPDLXBTJOWPMWFETPGSFRVFOUMZEVFUPBCBEUBCMFEFTJHO 6/)"11:&9$&15*0/ )"/%-*/()&3& Twitter @jnchito / GitHub JunichiIto
  8. $PODMVTJPO8IBUDBOXFMFBSOGSPNUIJTTUPSZ ➤ 5IFNJTVTFPGFYDFQUJPOIBOEMJOHMFBETUFSSJCMFDPOTFRVFODFT ➤ 8IBUZPVDBOEPBOEXIBUZPVTIPVME PSTIPVMEO`U EPBSFEJ⒎FSFOU ➤ *GZPVEPO`UDPOpEFODFJOFYDFQUJPOIBOEMJOHT 

    ➤ %0/05VTFASFTDVFATPDBTVBMMZ ➤ %FMFHBUFFYDFQUJPOIBOEMJOHUPGSBNFXPSLT QBHF MPHHJOH FUD  ➤ "TLNFOUPSTGPSIFMQBCPVUZPVSDPEFEFTJHO ➤ -FU`TEPIBQQZFYDFQUJPOIBOEMJOH❤ Twitter @jnchito / GitHub JunichiIto
  9. "#065.& ➤ +VOJDIJ*UP $BMMNF+VO  ➤ 4PGUXBSF&OHJOFFSBU4POJD(BSEFO*OD ➤ %FWFMPQJOH3BJMTBQQMJDBUJPOT ➤

    Twitter @jnchito ➤ GitHub JunichiIto
  10. 1&340/"-803,4 ➤ 5SBOTMBUFE&WFSZEBZ3BJMT5FTUJOHXJUI34QFD https://leanpub.com/everydayrailsrspec-jp

  11. 1&340/"-803,4 ➤ 8SPUFBCPPLDBMMFE*OUSPEVDUJPOUP3VCZ 1SPHSBNNJOHGPS'VUVSF1SPGFTTJPOBMT https://ruby-book.jnito.com/en While reading the manuscript, I

    felt many times "Oh, this is what it means to truly understand other people's feelings." This book is definitely useful for everyone to go on to the "next step”. From the foreword by Matz English Publisher W anted! “Learn Ruby Before Rails.
  12. 5)"/,:06 Twitter @jnchito GitHub JunichiIto Book https://ruby-book.jnito.com/en