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 4 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

      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

        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

          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
          • TIGT Offline
            TIG Moderator
            last edited by

            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
            • tt_suT Offline
              tt_su
              last edited by

              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
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement