The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mac::Safari::JavaScript::Exception - exception class to represent JS errors

SYNOPSIS

  use Mac::Safari::JavaScript qw(safari_js);
  
  eval {
    safari_js "compile time error!";
  };
  
  if ($@) {
     say "'$@' at line ".$@->line;
  }

DESCRIPTION

Error class for errors originating from Mac::Safari::JavaScript.

Constructors

new(%params)

Creates a new instance of the object. Expects the read only attributes (described below) as parameters. You shouldn't have to ever call this - these objects should be constructed by Mac::Safari::JavaScript

Accessors

The following read only accessors are avalible

error

The original error object.

name

The type of the error. This can be one of the following:

CustomError
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError

The name CustomError will be used for any error thrown with the throw keyword by you in your code. Other error codes are assigned by Safari based on the type of exception that occurs.

message

The string describing the error as set by the browser. This value will not be set if you simply throw a string (the string will be contained in the error accessor)

line

The line number the error occured on.

This is only set for browser raised errors or if you throw an exception object. Throwing a string will not

expressionBeginOffset

This value is not avalble on modern Safari (since Version 5.1.3 (7534.53.10)). This will only be set if you manually throw an exception object (and only an object, not a string.)

The index of the first character of your source code that threw the exception object.

expressionEndOffset

This value is not avalble on modern Safari (since Version 5.1.3 (7534.53.10)). This will only be set if you manually throw an exception object (and only an object, not a string.)

The index of the last character of your source code that threw the exception object.

sourceId

The unique identifier for the originating source of the error.

(The odd case for this accessor matches the odd case that Safari itself uses)

Methods

to_string

The stringiftication of this error.

This method is automatically called if you use this object in a string context.

AUTHOR

Written by Mark Fowler <mark@twoshortplanks.com>

Copryright Mark Fowler 2011. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

BUGS

Bugs should be reported to me via the CPAN RT system. http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mac::Safari::JavaScript

SEE ALSO

Mac::Safari::JavaScript