Author Topic: Throwing Errors  (Read 123 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 651
Throwing Errors
« on: December 02, 2018, 03:55:07 PM »
Hey .NET guys!
When defining a method by using the LispFunction attribute, like so
Code - C#: [Select]
  1. [LispFunction("Test")]
  2. public static void Test(ResultBuffer rbArgs)
  3. {
  4.  ...
  5. }

Normally one would provide the arguments from LISP and then we'd iterate through the ResultBuffer to check if they are valid/as expected for the method.
But how to throw the errors like in these standard LISP functions ? :

Code - Auto/Visual Lisp: [Select]
  1. _$ (rtos "a")
  2. ; error: bad argument type: numberp: "a"
  3. _$ (strcat 0 1)
  4. ; error: bad argument type: stringp 0
  5. _$ (getint "Here" "I" "Provide" "Many" "Arguments")
  6. ; error: too many arguments

I'm looking for something like this guide but that would work for ACAD
Code - C#: [Select]
  1. throw new System.ArgumentException("Parameter cannot be null", "original");

gile

  • Water Moccasin
  • Posts: 2172
  • Marseille, France
Re: Throwing Errors
« Reply #1 on: December 02, 2018, 04:12:08 PM »
Hi,

AFAIK there's no way to throw standard LISP error from .NET. You can see this topic and this one.
Speaking English as a French Frog

Grrr1337

  • Swamp Rat
  • Posts: 651
Re: Throwing Errors
« Reply #2 on: December 02, 2018, 04:54:49 PM »
Thank you gile!
I see some nice coding in these threads.. :)

Just an additional question (as I don't have enough experience), whats more acceptable:
To compile the classes (for instance the one you posted) onto a separate .dll file and then include it as reference to the main project
To add a new class within the main project (.cs) , and copy-paste the certain sub-library with all the namespaces and classes in there