| JavaScript documentation | Contained in the JavaScript distribution. |
JavaScript::Error - Encapsulates errors thrown from JavaScript
The cause of the exception.
The name of the file that the caused the exception.
The line number in the file that caused the exception.
A stringification of the exception in the format $message at $line in $file
Returns the stacktrace for the exception as a list of hashrefs containing function, file and lineno.
This class overloads stringification an will return the result from the method as_string.
| JavaScript documentation | Contained in the JavaScript distribution. |
package JavaScript::Error; use strict; use warnings; use overload q{""} => 'as_string', fallback => 1; sub as_string { my $self = shift; return "$self->{message} at $self->{fileName} in $self->{lineNumber}"; } sub message { return $_[0]->{message}; } sub file { return $_[0]->{fileName}; } sub line { return $_[0]->{lineNumber}; } sub stacktrace { my $stack = $_[0]->{stack}; return () unless $stack; return map { /^(.*?)\@(.*?):(\d+)$/ && { function => $1, file => $2, lineno => $3 } } split /\n/, $stack; } 1; __END__