See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: Error Trap issue

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Error Trap issue

    Hi All
    I have an error trap that I have been using for years and I recently notice that it was not really working correctly. When I purposely cause an error I get the following message:
    Undoing. . .
    Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
    Converting (command) calls to (command-s) is recommended.

    I typically add the top of all of my function (CM:ERR) which is loaded in my toolbox of functions. I am setting cm_undo_it within the routine I am having trouble with. Any help is greatly appreciated.

    Manuel


    Code:
    (defun CM:ERR ()
       (if (null *debug*)
         (progn
           (setq errfun *error*)
           (defun *ERROR* (msg)(sys_err msg))
         )
         (setq *error* nil)
       )
    (princ)
    )
    (defun sys_err (errmsg /)
       (if errfun (setq *error* errfun errfun nil))
       (while (> (getvar "CMDACTIVE") 0)(command)) ;_  end while
       (if (and errmsg (null (member errmsg '("Function cancelled" "quit / exit abort"))))
         (princ (strcat "\n** Error: " errmsg " ** "))
       )
       (if cm_undo_it
         (progn
           (princ "\nUndoing. . . ")
           (command ".undo" "end" ".undo" 1)
           (setq cm_undo_it nil)
         )
         (vla-EndUndoMark (vla-get-activedocument (vlax-get-acad-object))) ;modified 1-22-09
       )
       (CM:MODER) 
    )

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Error Trap issue

    Looks complicated, do you really need to use (command) to cancel active commands? Ever consider using *ERROR* as a local variable? I never modify *ERROR* globally. You need to update those toolbox functions, (command-s) was added in 2012.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    1

    Default Re: Error Trap issue

    I too used a generic 'toolbox' error trap, and found it to be too cumbersome, and hard to make 'custom' for any given routine, which ultimately ends up functioning just like the native error trap, which doesn't have the subsequent requirement of first storing, then restoring, etc, nor any of the implicit dependencies.

    I later learned the value of localizing *error* within the Defun, which allowed me complete autonomy to be able to handle each routine's needs... A bit more duplication of code, but it's easier to maintain, isn't dependent on other 'toolbox' functions, and is more portable to distribute to others in-house as well as in forums, etc.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Error Trap issue

    I stopped using the *Error* method for trapping errors in favor of full error handling like try catch in .net. Using the standard errortrap function i can pass almost any function to it and trap the error to any line of code or any sub/function.

    This allows for on error resume next functionality that doesn't stop the routine if an error is encountered.

    P=

  5. #5
    Member
    Join Date
    2000-11
    Posts
    12
    Login to Give a bone
    0

    Default Re: Error Trap issue

    Did you ever get a solution for this. Am having the same issue.

    Raudel Hinojosa

Similar Threads

  1. 2013: P Trap Problem
    By psmith516419 in forum Revit MEP - Families
    Replies: 1
    Last Post: 2013-05-30, 04:00 PM
  2. P-Trap Rotate
    By cdsuggs in forum Revit MEP - Families
    Replies: 9
    Last Post: 2010-09-07, 05:06 PM
  3. Help with error trap needed
    By d_m_hopper in forum AutoLISP
    Replies: 8
    Last Post: 2009-10-26, 12:48 PM
  4. P-trap
    By Wagurto in forum Revit MEP - General
    Replies: 3
    Last Post: 2009-06-15, 12:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •