diff options
author | Jose <jose@zeroc.com> | 2019-04-11 18:43:22 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-04-11 18:43:22 +0200 |
commit | 676d84d9071eb1e36e63e130d940c8c69762f71b (patch) | |
tree | 51895d2ebd9565510cfdd8b89e56c910b0b595fb /swift/src | |
parent | Ice/admin test (diff) | |
download | ice-676d84d9071eb1e36e63e130d940c8c69762f71b.tar.bz2 ice-676d84d9071eb1e36e63e130d940c8c69762f71b.tar.xz ice-676d84d9071eb1e36e63e130d940c8c69762f71b.zip |
Fix checkedCast to handle FacetNotExistsException
Diffstat (limited to 'swift/src')
-rw-r--r-- | swift/src/Ice/Proxy.swift | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/swift/src/Ice/Proxy.swift b/swift/src/Ice/Proxy.swift index 978048db125..bb819639766 100644 --- a/swift/src/Ice/Proxy.swift +++ b/swift/src/Ice/Proxy.swift @@ -734,12 +734,15 @@ open class _ObjectPrxI: ObjectPrx { public static func checkedCast<ProxyImpl>(prx: ObjectPrx, facet: String? = nil, context: Context? = nil) throws -> ProxyImpl? - where ProxyImpl: _ObjectPrxI { - let objPrx = facet != nil ? prx.ice_facet(facet!) : prx - guard try objPrx.ice_isA(id: ProxyImpl.ice_staticId(), context: context) else { + where ProxyImpl: _ObjectPrxI { + do { + let objPrx = facet != nil ? prx.ice_facet(facet!) : prx + guard try objPrx.ice_isA(id: ProxyImpl.ice_staticId(), context: context) else { + return nil + } + } catch is FacetNotExistsException { return nil } - return ProxyImpl(from: objPrx) } public static func uncheckedCast<ProxyImpl>(prx: ObjectPrx, |