Class List Method List File List

# Exception: OSX::OCException

Inherits:
  RuntimeError
  - Object
  - RuntimeError
  - OSX::OCException
  show all
Defined in:
  src/ruby/osx/objc/oc_exception.rb

## Overview

Represents NSException in Ruby world.

Examples:

    ary = OSX::NSMutableArray.alloc.init
    ary.addObject(nil)
    => OSX::OCException: NSInvalidArgumentException - ***
        -[__NSArrayM insertObject:atIndex:]: object cannot be nil

## Instance Attribute Summary (collapse)

- - (Object) name readonly

  Returns the value of attribute name.

- - (Object) nsexception readonly

  Returns the value of attribute nsexception.

- - (Object) reason readonly

  Returns the value of attribute reason.

- - (Object) userInfo readonly

  Returns the value of attribute userInfo.

## Instance Method Summary (collapse)

- - (OCException) initialize(ocexcp, msg = nil) constructor

  A new instance of OCException.

## Constructor Details

### - (`OCException`) initialize(ocexcp, msg = nil)

Returns a new instance of OCException

Parameters:

- ocexcp (`OSX::NSException`)
- msg (`String`) (defaults to: `nil`)

    27
    28
    29
    30
    31
    32
    33
    34

    # File 'src/ruby/osx/objc/oc_exception.rb', line 27

    def initialize(ocexcp, msg = nil)
      @nsexception = ocexcp
      @name = @nsexception.objc_send(:name).to_s
      @reason = @nsexception.objc_send(:reason).to_s
      @userInfo = @nsexception.objc_send(:userInfo)
      msg = "#{@name} - #{@reason}" if msg.nil?
      super(msg)
    end

## Instance Attribute Details

### - (`Object`) name (readonly)

Returns the value of attribute name

    23
    24
    25

    # File 'src/ruby/osx/objc/oc_exception.rb', line 23

    def name
      @name
    end

### - (`Object`) nsexception (readonly)

Returns the value of attribute nsexception

    23
    24
    25

    # File 'src/ruby/osx/objc/oc_exception.rb', line 23

    def nsexception
      @nsexception
    end

### - (`Object`) reason (readonly)

Returns the value of attribute reason

    23
    24
    25

    # File 'src/ruby/osx/objc/oc_exception.rb', line 23

    def reason
      @reason
    end

### - (`Object`) userInfo (readonly)

Returns the value of attribute userInfo

    23
    24
    25

    # File 'src/ruby/osx/objc/oc_exception.rb', line 23

    def userInfo
      @userInfo
    end