Author Topic: Error handling with style  (Read 1546 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Error handling with style
« on: March 16, 2018, 01:59:04 PM »
Code: [Select]
(defun *error* (msg)
  (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
    (progn (vl-bt)
           (command-s "_.browser" (strcat "https://www.google.com/search?q=\"" msg "\""))
           (princ (strcat "\nError: " msg))
    )
  )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Error handling with style
« Reply #1 on: March 16, 2018, 02:00:32 PM »
I like it. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Error handling with style
« Reply #2 on: March 16, 2018, 02:36:29 PM »
Certainly with style!  :-D

BTW got me thinking is there alternative to open a url with scripting objects instead of:
Code: [Select]
  (command-s "_.browser" (strcat "https://www.google.com/search?q=\"" msg "\""))
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Error handling with style
« Reply #3 on: March 16, 2018, 02:36:53 PM »
Fixed.

Code: [Select]
(defun *error* ( msg )

    (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
        (progn
            (vl-bt)
            (command-s "_.browser"
                (strcat
                    "https://www.google.com/search?q=site:theswamp.org \""
                    msg
                    "\""
                )
            )
            (princ (strcat "\nError: " msg))
        )
    )
   
    (princ)
   
)

 :-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Error handling with style
« Reply #4 on: March 16, 2018, 02:43:39 PM »
That's about the truth.

Fixed.

Code: [Select]
(defun *error* ( msg )

    (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
        (progn
            (vl-bt)
            (command-s "_.browser"
                (strcat
                    "https://www.google.com/search?q=site:theswamp.org \""
                    msg
                    "\""
                )
            )
            (princ (strcat "\nError: " msg))
        )
    )
   
    (princ)
   
)

 :-D
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox