Error
An Error is created by RocketLang if unallowed or invalid code is run. An error does often replace the original return value of a function or identifier. The documentation of those functions does indicate ERROR as a potential return value.
A program can rescue from errors within a block or alter it's behavior within other blocks like 'if' or 'def'.
def test()
puts(nope)
rescue e
puts("Got error: '" + e.msg() + "'")
end
test()
=> "Got error in if: 'identifier not found: error'"
if (true)
nope()
rescue your_name
puts("Got error in if: '" + your_name.msg() + "'")
end
=> "Got error in if: 'identifier not found: nope'"
begin
puts(nope)
rescue e
puts("rescue")
end
=> "rescue"
Literal Specific Methodsโ
msg()โ
Returns
STRING
Returns the error message
Please note that performing .msg()
on a ERROR object does result in a STRING object which then will no longer be treated as an error!
ยป def ()
puts(nope)
rescue e
puts((rescued error: + e.msg()))
end
๐ ยป test()
"rescued error:identifier not found: nope"
Generic Literal Methodsโ
methods()โ
Returns
ARRAY
Returns an array of all supported methods names.
๐ > "test".methods()
=> [count, downcase, find, reverse!, split, lines, upcase!, strip!, downcase!, size, plz_i, replace, reverse, strip, upcase]
to_json()โ
Returns
STRING|ERROR
Returns the object as json notation.
๐ > a = {"test": 1234}
=> {"test": 1234}
๐ > a.to_json()
=> "{"test":1234}"
type()โ
Returns
STRING
Returns the type of the object.
๐ > "test".type()
=> "STRING"
wat()โ
Returns
STRING
Returns the supported methods with usage information.
๐ > true.wat()
=> BOOLEAN supports the following methods:
plz_s()