# Exception handling in iOS framework

**URL:** <https://discuss.kotlinlang.org/t/exception-handling-in-ios-framework/6163>\
**Category:** Native\
**Created:** [January 9, 2018, 3:15pm UTC](https://discuss.kotlinlang.org/t/exception-handling-in-ios-framework/6163 "2018-01-09T15:15:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattmook](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/mattmook/32/4637_2.png) [@mattmook](https://discuss.kotlinlang.org/u/mattmook)\
**Post date:** [January 9, 2018, 3:15pm UTC](https://discuss.kotlinlang.org/t/exception-handling-in-ios-framework/6163/1 "2018-01-09T15:15:53Z")

</div>

I’m creating an iOS framework using Kotlin/Native 0.5, however am not sure how you are supposed to handle exceptions properly.

Given the following class:

```
class TestClass() {
    fun alwaysThrows() {
        throw IllegalArgumentException("accountId not valid")
    }
}

```

When `alwaysThrows` is called then an exception is thrown. With interop with Swift or Obj-C you would like to be able to catch this exception however the app aborts with “Uncaught Kotlin exception: kotlin.IllegalArgumentException” regardless of what Swift or Obj-C code you wrap it with.

For example, I’ve tried @try/@catch in Obj-C, try in Swift:

```
@try {
    [[TestClass alloc] init] alwaysThrows]
}
@catch (id exception) {
    ...
}

```

How should exceptions be handled from Swift/Obj-C interop code?
