From 750af31a8065c34d45302e4672eab487ef559b5e Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Fri, 26 Mar 2021 15:54:27 +0100 Subject: [PATCH] Don't localize error messages --- docs/docs/guides/ERRORS.mdx | 2 +- ios/CameraView.swift | 6 +++--- ios/PhotoCaptureDelegate.swift | 4 ++-- ios/React/Promise.swift | 2 +- ios/VideoCaptureDelegate.swift | 2 +- src/CameraError.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/docs/guides/ERRORS.mdx b/docs/docs/guides/ERRORS.mdx index e8ee2be..5e6e6f4 100644 --- a/docs/docs/guides/ERRORS.mdx +++ b/docs/docs/guides/ERRORS.mdx @@ -42,7 +42,7 @@ The `CameraError` type is a baseclass type for all other errors and provides the * `code`: A typed code in the form of `{domain}/{code}` that can be used to quickly identify and group errors * `message`: A non-localized message text that provides a more information and context about the error and possibly problematic values. * `cause?`: An `ErrorWithCause` instance that provides information about the cause of the error. (Optional) - * `cause.message`: The message of the error that caused the camera error. This is localized on iOS. + * `cause.message`: The message of the error that caused the camera error. * `cause.code?`: The native error's error-code. (iOS only) * `cause.domain?`: The native error's domain. (iOS only) * `cause.details?`: More dictionary-style information about the cause. (iOS only) diff --git a/ios/CameraView.swift b/ios/CameraView.swift index f43934e..2bc3bb9 100644 --- a/ios/CameraView.swift +++ b/ios/CameraView.swift @@ -203,7 +203,7 @@ final class CameraView: UIView { self.captureSession.startRunning() } } - invokeOnError(.unknown(message: error.localizedDescription), cause: error as NSError) + invokeOnError(.unknown(message: error.description), cause: error as NSError) } internal final func setTorchMode(_ torchMode: String) { @@ -251,7 +251,7 @@ final class CameraView: UIView { causeDictionary = [ "code": cause.code, "domain": cause.domain, - "message": cause.localizedDescription, + "message": cause.description, "details": cause.userInfo, ] } @@ -296,7 +296,7 @@ final class CameraView: UIView { // activate current audio session because camera is active try audioSession.setActive(true) } catch let error as NSError { - self.invokeOnError(.session(.audioSessionSetupFailed(reason: error.localizedDescription)), cause: error) + self.invokeOnError(.session(.audioSessionSetupFailed(reason: error.description)), cause: error) setAutomaticallyConfiguresAudioSession(true) } let end = DispatchTime.now() diff --git a/ios/PhotoCaptureDelegate.swift b/ios/PhotoCaptureDelegate.swift index b0c79a5..0d7e475 100644 --- a/ios/PhotoCaptureDelegate.swift +++ b/ios/PhotoCaptureDelegate.swift @@ -28,7 +28,7 @@ class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegate { delegatesReferences.removeAll(where: { $0 == self }) } if let error = error { - return promise.reject(error: .capture(.unknown(message: error.localizedDescription)), cause: error as NSError) + return promise.reject(error: .capture(.unknown(message: error.description)), cause: error as NSError) } let error = ErrorPointer(nilLiteral: ()) @@ -67,7 +67,7 @@ class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegate { delegatesReferences.removeAll(where: { $0 == self }) } if let error = error { - return promise.reject(error: .capture(.unknown(message: error.localizedDescription)), cause: error as NSError) + return promise.reject(error: .capture(.unknown(message: error.description)), cause: error as NSError) } } diff --git a/ios/React/Promise.swift b/ios/React/Promise.swift index 48d4d47..e37f65c 100644 --- a/ios/React/Promise.swift +++ b/ios/React/Promise.swift @@ -58,7 +58,7 @@ func withPromise(_ promise: Promise, _ block: () throws -> Any?) { } catch let error as CameraError { promise.reject(error: error) } catch let error as NSError { - promise.reject(error: CameraError.unknown(message: error.localizedDescription), cause: error) + promise.reject(error: CameraError.unknown(message: error.description), cause: error) } } diff --git a/ios/VideoCaptureDelegate.swift b/ios/VideoCaptureDelegate.swift index dca742e..ecbd9ac 100644 --- a/ios/VideoCaptureDelegate.swift +++ b/ios/VideoCaptureDelegate.swift @@ -34,7 +34,7 @@ class RecordingDelegateWithCallback: NSObject, AVCaptureFileOutputRecordingDeleg delegateReferences.removeAll(where: { $0 == self }) } if let error = error { - return callback([NSNull(), makeReactError(.capture(.unknown(message: error.localizedDescription)), cause: error as NSError)]) + return callback([NSNull(), makeReactError(.capture(.unknown(message: error.description)), cause: error as NSError)]) } let seconds = CMTimeGetSeconds(output.recordedDuration) diff --git a/src/CameraError.ts b/src/CameraError.ts index 7927f40..d7146da 100644 --- a/src/CameraError.ts +++ b/src/CameraError.ts @@ -55,7 +55,7 @@ export interface ErrorWithCause { */ domain?: string; /** - * The native error description (Localized on iOS) + * The native error description * * * iOS: `NSError.message` * * Android: `Throwable.message`