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
message
is set to the argument. Otherwise, themessage
is 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_error
with that object would return true), return the argument as is.Otherwise, create and return a new
Web::DOM::Error
object whosemessage
is the value obtained by evaluating the argument as a string (Something's wrong
if the value isundef
or 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->name
returns a string.-
The returned value should be a short string identifying the type of the error.
$error->message
returns a string.-
The returned value should be a short English string describing the error.
$error->file_name
returns 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_number
returns 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_name
and 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.