Web::DOM::Error
Error object
DESCRIPTION
The Web::DOM::Error object represents an error or exception.
This class is intended to be equivalent to ECMAScript Error objects,
modified to be compatible with Perl's convention.
There are also subclasses: Web::DOM::Exception and Web::DOM::TypeError.
METHODS
Following methods are available:
$error = Web::DOM::Error->new ($message)-
Create and return a new error object.
If a character string is specified as an argument, the error's
messageis set to the argument. Otherwise, themessageis set to the empty string. $string = $error->name-
Return the name of the error, e.g.
TimeoutError. $string = $error->message-
Return a short message describing the error. This message can be used for debugging purpose. The value returned by this method is implementation-dependent. Applications should not rely on the value returned by this method.
$string = $error->file_name-
Return the file name of the location of the error. It is intended to be a short string similar to
__FILE__. $number = $error->line_number-
Return the line number, in the file, of the location of the error. It is intended to be an integer similar to
__LINE__. $string = '' . $error$string = $error->stringify-
Stringifying the error object returns the error message with its location in the Perl standard format (i.e.
Error message at path/to/script.pl line 123.\n). $error = Web::DOM::Error->wrap ($value)-
If the argument is an error object (
Web::DOM::Error->is_errorwith that object would return true), return the argument as is.Otherwise, create and return a new
Web::DOM::Errorobject whosemessageis the value obtained by evaluating the argument as a string (Something's wrongif the value isundefor the empty string). $boolean = Web::DOM::Error->is_error ($error)-
Return whether the argument is an object implementing the Perl Error Object Interface Level 1 (see "ERROR OBJECT API").
ERROR OBJECT API
A value $error is implementing the Perl Error Object Interface Level 1 iff all of the following conditions are true:
$error->namereturns a string.-
The returned value should be a short string identifying the type of the error.
$error->messagereturns a string.-
The returned value should be a short English string describing the error.
$error->file_namereturns a string.-
The returned value should be a short string identifying the location of the Perl script throwing the error. It should not contain U+000D or U+000A.
$error->line_numberreturns an integer.-
The returned value should be a line number identifying the location of the error within the script denoted by
$error->file_name. '' . $error (i.e. evaluation as a string) returns a string.-
The returned value must end with
at FILE line LINE.followed by\n, where FILE is$error->file_nameand LINE is$error->line_number. It should also contain the$error->message. $Web::DOM::Error::L1ObjectClass->{ref $error}is true.
An instance of the Web::DOM::Error class is implementing the Perl Error Object Interface Level 1.
SEE ALSO
ECMAScript Error Objects <https://tc39.github.io/ecma262/#sec-error-objects>.
AUTHOR
Wakaba <wakaba@suikawiki.org>.
LICENSE
Copyright 2012-2017 Wakaba <wakaba@suikawiki.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.