Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unhappy Exception Handling

Junichi Ito
November 15, 2018

Unhappy Exception Handling

I talked at Ruby Conf 2018 lightning talks.

Junichi Ito

November 15, 2018
Tweet

More Decks by Junichi Ito

Other Decks in Programming

Transcript

  1. 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
  2. *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
  3. 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
  4. $PODMVTJPO8IBUDBOXFMFBSOGSPNUIJTTUPSZ ➤ 5IFNJTVTFPGFYDFQUJPOIBOEMJOHMFBETUFSSJCMFDPOTFRVFODFT ➤ 8IBUZPVDBOEPBOEXIBUZPVTIPVME PSTIPVMEO`U EPBSFEJ⒎FSFOU ➤ *GZPVEPO`UDPOpEFODFJOFYDFQUJPOIBOEMJOHT 

    ➤ %0/05VTFASFTDVFATPDBTVBMMZ ➤ %FMFHBUFFYDFQUJPOIBOEMJOHUPGSBNFXPSLT QBHF MPHHJOH FUD  ➤ "TLNFOUPSTGPSIFMQBCPVUZPVSDPEFEFTJHO ➤ -FU`TEPIBQQZFYDFQUJPOIBOEMJOH❤ Twitter @jnchito / GitHub JunichiIto
  5. 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.