Exception: Exception

Defined in:
opal/opal/corelib/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Exception

Returns a new instance of Exception



18
19
20
# File 'opal/opal/corelib/error.rb', line 18

def initialize(message)
  `self.message = message`
end

Instance Attribute Details

#messageObject (readonly) Also known as: to_s

Returns the value of attribute message



2
3
4
# File 'opal/opal/corelib/error.rb', line 2

def message
  @message
end

Class Method Details

.new(message = 'Exception') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'opal/opal/corelib/error.rb', line 4

def self.new(message = 'Exception')
  %x{
    var err = new self.$$alloc(message);

    if (Error.captureStackTrace) {
      Error.captureStackTrace(err);
    }

    err.name = self.$$name;
    err.$initialize(message);
    return err;
  }
end

Instance Method Details

#backtraceObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'opal/opal/corelib/error.rb', line 22

def backtrace
  %x{
    var backtrace = self.stack;

    if (typeof(backtrace) === 'string') {
      return backtrace.split("\n").slice(0, 15);
    }
    else if (backtrace) {
      return backtrace.slice(0, 15);
    }

    return [];
  }
end

#inspectObject



37
38
39
# File 'opal/opal/corelib/error.rb', line 37

def inspect
  "#<#{self.class}: '#@message'>"
end