Lodash - debugging
API
.alert()
.alert(valueOrTemplate: any { ; …templateParams : any})
A convenience function that does the equivalent of:
ALERT(_.format(_.toString(valueOrTemplate) { ; …templateParams }))
You will never want to use ALERT
after using this function, for two reasons:
You can throw any value at this function and it will turn it into a string.
You can pass in a template string and parameters, and it will format them for you.
Example
_.alert("The current time is ${1|time:5} on ${2|3}."; Current time; Current date)
.inspect()
.inspect(value : any { ; pretty : Boolean })
A convenience debugging function for displaying the description of value in an alert. By default pretty is true.
The primary difference between this function and _.alert()
is that this function will display a description of value in an alert (using .description()
, whereas _.alert()
will display a string version of value itself by calling .toString()
.
For example, whereas _.alert()
will display the string "foo" as foo
— with no indication it is a string — this function will display the string "foo" as "foo"
.
.openMethod()
.openMethod(method : Text)
.openMethod(stackFrame : Object)
A convenience function that calls .resolveMethodRef()
and then opens the method or class function.
.resolveMethodRef()
.resolveMethodRef(*method : Text { ; line : Integer) : Object
.resolveMethodRef(stackFrame : Object { ; line : Integer) : Object
Given a method or class function name and optionally a line number, or a stack frame from GET LAST ERROR STACK
or .getCallStack()
, returns an object with two properties:
Property | Type | Description |
---|---|---|
.path | Text | The path to the method/function in a form that can be used with METHOD OPEN PATH |
.line | Integer | The line number within the method/function |
This is especially useful for going to the line in a class function that caused an error, because Error method
will be something like "MyClass.someFunction" and Error line
will be the line within that function, but METHOD OPEN PATH
can only be given a reference to the the class definition and a line number within the entire class definition.
So, given this class definition for the class Foo
:
Class constructor()
This.foo:="bar"
Function foo()
For ($i; 1; 100)
This.barr() // This will cause an error
End for
Function bar()
// do something
If you execute foo()
, within an error handler Error method
will be "Foo.foo" and Error line
will be 2. To correctly open the class definition to that line, you would do this:
$ref:=_.resolveMethodRef(Error method; Error line)
METHOD OPEN PATH($ref.path; $ref.line)
NOTE
This function currently only works with class functions and project methods (not form or object methods).