sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Throw exception when required file does not exist?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 223 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jim
      last edited by

      I wanted to do this:

      
      begin
        require 'file'
      rescue 
        # 
      end
      
      

      But it does work? Why not?

      I know I can do it other ways, but I'm just curious if there's a reason for the behavior.

      Hi

      1 Reply Last reply Reply Quote 0
      • AdamBA Offline
        AdamB
        last edited by

        rescue with no argument will default to StandardError.
        What you want is:

        begin require 'foods' rescue LoadError puts "not there" end

        Developer of LightUp Click for website

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          Ah! Thank you Adam.

          But I think I may just be being too lazy to check if the files exists...

          Hi

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement