sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Throw exception when required file does not exist?

    scheduled pinned locked moved Developers' Forum
    3 Posts 2 Posters 242 Views 2 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • 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

      one-reply-to-this-post last-reply-time 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

        one-reply-to-this-post last-reply-time 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

          one-reply-to-this-post last-reply-time 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