diff --git a/docs/ERRORS.md b/docs/ERRORS.md index 73fd6bb..f5f51a0 100644 --- a/docs/ERRORS.md +++ b/docs/ERRORS.md @@ -46,6 +46,8 @@ The `CameraError` type is a baseclass type for all other errors and provides the * `message`: A non-localized message text that provides a more information and context about the error and possibly problematic values. * (optional) `cause`: An `ErrorWithCause` instance that provides information about the cause of the error. * `cause.message`: The message of the error that caused the camera error. This is localized on iOS. + * (iOS) `cause.code`: The native error's error-code. (iOS only) + * (iOS) `cause.domain`: The native error's domain. (iOS only) * (iOS) `cause.details`: More dictionary-style information about the cause. (iOS only) * (Android) `cause.stacktrace`: A native Java stacktrace for the cause. * (optional) `cause.cause`: The cause that caused the given error. (Recursive) diff --git a/ios/CameraView.swift b/ios/CameraView.swift index 597fa2b..d05f980 100644 --- a/ios/CameraView.swift +++ b/ios/CameraView.swift @@ -463,7 +463,12 @@ final class CameraView: UIView { var causeDictionary: [String: Any]? if let cause = cause { - causeDictionary = ["message": cause.localizedDescription, "details": cause.userInfo] + causeDictionary = [ + "code": cause.code, + "domain": cause.domain, + "message": cause.localizedDescription, + "details": cause.userInfo + ] } onError([ "code": error.code, diff --git a/src/CameraError.ts b/src/CameraError.ts index 38f2e7d..3487971 100644 --- a/src/CameraError.ts +++ b/src/CameraError.ts @@ -37,6 +37,20 @@ export type SystemError = 'system/no-camera-manager'; export type UnknownError = 'unknown/unknown'; export interface ErrorWithCause { + /** + * The native error's code. + * + * * iOS: `NSError.code` + * * Android: N/A + */ + code?: number; + /** + * The native error's domain. + * + * * iOS: `NSError.domain` + * * Android: N/A + */ + domain?: string; /** * The native error description (Localized on iOS) *