@@ -37,31 +37,31 @@ final class ObjectHookStrategy: HookStrategy {
3737 interposeSubclass!. dynamicClass
3838 }
3939
40- func validate( ) throws ( InterposeError ) {
40+ func validate( ) throws {
4141 guard class_getInstanceMethod ( self . class, self . selector) != nil else {
42- throw . methodNotFound( class: self . class, selector: self . selector)
42+ throw InterposeError . methodNotFound ( class: self . class, selector: self . selector)
4343 }
4444
4545 if let _ = checkObjectPosingAsDifferentClass ( self . object) {
4646 if object_isKVOActive ( self . object) {
47- throw . kvoDetected( object)
47+ throw InterposeError . kvoDetected ( object)
4848 }
4949 // TODO: Handle the case where the object is posing as different class but not the interpose subclass
5050 }
5151 }
5252
53- func replaceImplementation( ) throws ( InterposeError ) {
53+ func replaceImplementation( ) throws {
5454 let hookIMP = self . makeHookIMP ( )
5555 self . appliedHookIMP = hookIMP
5656 ObjectHookRegistry . register ( self . handle, for: hookIMP)
5757
5858 guard let method = class_getInstanceMethod ( self . class, self . selector) else {
59- throw . methodNotFound( class: self . class, selector: self . selector)
59+ throw InterposeError . methodNotFound ( class: self . class, selector: self . selector)
6060 }
6161
6262 // The implementation of the call that is hooked must exist.
6363 guard self . lookUpIMP ( ) != nil else {
64- throw . implementationNotFound(
64+ throw InterposeError . implementationNotFound (
6565 class: self . class,
6666 selector: self . selector
6767 )
@@ -89,7 +89,7 @@ final class ObjectHookStrategy: HookStrategy {
8989 // This should not happen if the class implements the method or we have installed
9090 // the super trampoline. Instead, we should make the trampoline implementation
9191 // failable.
92- throw . implementationNotFound(
92+ throw InterposeError . implementationNotFound (
9393 class: self . dynamicSubclass,
9494 selector: self . selector
9595 )
@@ -103,29 +103,29 @@ final class ObjectHookStrategy: HookStrategy {
103103 Interpose . log ( " Added -[ \( self . class) . \( self . selector) ] IMP: \( hookIMP) via replacement " )
104104 } else {
105105 Interpose . log ( " Unable to replace: -[ \( self . class) . \( self . selector) ] IMP: \( hookIMP) " )
106- throw . unableToAddMethod( self . class, self . selector)
106+ throw InterposeError . unableToAddMethod ( self . class, self . selector)
107107 }
108108 } else {
109109 let didAddMethod = class_addMethod ( self . dynamicSubclass, self . selector, hookIMP, encoding)
110110 if didAddMethod {
111111 Interpose . log ( " Added -[ \( self . class) . \( self . selector) ] IMP: \( hookIMP) " )
112112 } else {
113113 Interpose . log ( " Unable to add: -[ \( self . class) . \( self . selector) ] IMP: \( hookIMP) " )
114- throw . unableToAddMethod( self . class, self . selector)
114+ throw InterposeError . unableToAddMethod ( self . class, self . selector)
115115 }
116116 }
117117 }
118118 }
119119
120- func restoreImplementation( ) throws ( InterposeError ) {
120+ func restoreImplementation( ) throws {
121121 guard let hookIMP = self . appliedHookIMP else { return }
122122 defer {
123123 imp_removeBlock ( hookIMP)
124124 self . appliedHookIMP = nil
125125 }
126126
127127 guard let method = class_getInstanceMethod ( self . class, self . selector) else {
128- throw . methodNotFound( class: self . class, selector: self . selector)
128+ throw InterposeError . methodNotFound ( class: self . class, selector: self . selector)
129129 }
130130
131131 guard self . storedOriginalIMP != nil else {
@@ -136,18 +136,18 @@ final class ObjectHookStrategy: HookStrategy {
136136 // We could recreate the whole class at runtime and rebuild all hooks,
137137 // but that seems excessive when we have a trampoline at our disposal.
138138 Interpose . log ( " Reset of -[ \( self . class) . \( self . selector) ] not supported. No IMP " )
139- throw . resetUnsupported( " No Original IMP found. SuperBuilder missing? " )
139+ throw InterposeError . resetUnsupported ( " No Original IMP found. SuperBuilder missing? " )
140140 }
141141
142142 guard let currentIMP = class_getMethodImplementation ( self . dynamicSubclass, self . selector) else {
143- throw . unknownError( " No Implementation found " )
143+ throw InterposeError . unknownError ( " No Implementation found " )
144144 }
145145
146146 // We are the topmost hook, replace method.
147147 if currentIMP == hookIMP {
148148 let previousIMP = class_replaceMethod ( self . dynamicSubclass, self . selector, self . storedOriginalIMP!, method_getTypeEncoding ( method) )
149149 guard previousIMP == hookIMP else {
150- throw . revertCorrupted(
150+ throw InterposeError . revertCorrupted (
151151 class: self . dynamicSubclass,
152152 selector: self . selector,
153153 imp: previousIMP
0 commit comments