• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Catch Load Errors

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 4 Posters 241 Views
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 8 Jan 2015, 10:06

    What is the best way to catch and log extension load errors? I would like for SketchUp to log errors to a file, maybe print a note in the Ruby Console, but not interrupt loading with the Load Errors dialog.

    I know I can redefine the load method, but I want to make sure I don't break something else.

    Hi

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 8 Jan 2015, 10:13

      This is for my own use - not for any that will be shared.

      Hi

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by 8 Jan 2015, 14:37

        Jim,

        Interesting question! What you request sounds like the switch many compilers provide to continue processing beyond the first error (with the addition that the error messages need to be captured somewhere accessible). Just as with a compiler, this would risk causing a cascade of nonsense errors from subsequent loaded files, but also just as with a compiler that might be a tradeoff the developer was willing to make.

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 8 Jan 2015, 15:22

          Something like ?
          Assuming we are loading a folder of scripts - 'some_folder_path'...

          msg = ""
          Dir.entries(some_folder_path).grep(/.rb$/).each{|rb|
            dest = File.join(some_folder_path, rb)
            begin
              load(dest)
            rescue Exception => err
              msg << "#{some_folder_path}/#{rb} >>> #{err}\n"
            end
          }
          file = File.open(path_to_report. "w")
            file.puts(msg)
          file.close
          
          

          In rare cases when there's a "load error" it is written into the 'path_to_report' file ?

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            tt_su
            last edited by 9 Jan 2015, 11:41

            One thing to beware of is that Sketchup::require/load annoyingly doesn't raise ruby errors - but instead just output the error text. So you might want to hook into $stdout and $strerr to catch that as well. (This is something I suggest only because you mention it was for a personal tool.)

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

            Advertisement