/// <summary> /// Converts an <see cref="NSError"/> to an <see cref="CoreLocationErrorCode"/> by casting its /// <see cref="NSError.code"/> to an <see cref="CoreLocationErrorCode"/>. /// </summary> /// <param name="error">The <see cref="NSError"/> being extended.</param> /// <returns>Returns the <see cref="NSError"/> as an <see cref="CoreLocationErrorCode"/>.</returns> /// <exception cref="System.InvalidCastException">Thrown if <paramref name="error"/>'s /// <see cref="NSError.ToErrorDomain"/> is not <see cref="NSErrorDomain.CoreLocation"/>.</exception> public static CoreLocationErrorCode AsCoreLocationErrorCode(this NSError error) { if (error.ToErrorDomain() != NSErrorDomain.CoreLocation) { throw new InvalidCastException($"{nameof(error)} is not a {nameof(NSErrorDomain.CoreLocation)} error."); } return((CoreLocationErrorCode)error.code); }
/// <summary> /// Converts an <see cref="NSError"/> to an <see cref="ARKitErrorCode"/> by casting its /// <see cref="NSError.code"/> to an <see cref="ARKitErrorCode"/>. /// </summary> /// <param name="error">The <see cref="NSError"/> being extended.</param> /// <returns>Returns the <see cref="NSError"/> as an <see cref="ARKitErrorCode"/>.</returns> /// <exception cref="System.InvalidCastException">Thrown if <paramref name="error"/>'s /// <see cref="NSError.ToErrorDomain"/> is not <see cref="NSErrorDomain.ARKit"/>.</exception> /// <seealso cref="ARKitSessionDelegate.OnSessionDidFailWithError"/> public static ARKitErrorCode AsARKitErrorCode(this NSError error) { if (error.ToErrorDomain() != NSErrorDomain.ARKit) { throw new InvalidCastException($"{nameof(error)} is not an {nameof(NSErrorDomain.ARKit)} error"); } return((ARKitErrorCode)error.code); }