Skip to content

RedRoma/SwiftExceptionCatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftExceptionCatcher

Carthage compatible Build Status

SwiftExceptionCatcher allows Swift Code to catch exceptions thrown from Objective-C code.

This is useful when using Thrift libraries, where it is perfectly normal for code to throw NSException types.

Carthage

Cocoapods

pod 'SwiftExceptionCatcher', :git => 'https://github.com/RedRoma/SwiftExceptionCatcher.git'

Using the RedRoma Repository

# RedRoma Repository
source 'https://github.com/RedRoma/CocoaSpecs.git'

pod 'SwiftExceptionCatcher', '1.0'

API

Simply wrap the code-in-play in the tryOp function call.

var object: SomeObjectThatThrows
...
do {
    try tryOp() { object.act() }
}
catch let ex is AromaException {
    print("Aroma Failed: \(ex")
}
catch let ex {
    print("Exception: \(ex")
}

About

Catch NSException and NSError with Swift 3+

Resources

License

Stars

Watchers

Forks

Packages

No packages published