fix: change types of parameters for js errors

This commit is contained in:
Nikita Semenov 2023-01-09 15:29:41 +03:00
parent c75ff4c1d0
commit 3e7307424a
2 changed files with 11 additions and 6 deletions

View File

@ -25,15 +25,20 @@ import Foundation
public struct WebViewJSError: WebViewError, Codable {
public let contentURL: URL?
public let name: String?
public let message: String?
public let message: Int?
public let stackTrace: String?
public init(contentURL: URL?,
public init(stringURL: String?,
name: String?,
message: String?,
message: Int?,
stackTrace: String?) {
self.contentURL = contentURL
if let stringURL = stringURL {
self.contentURL = URL(string: stringURL)
} else {
self.contentURL = nil
}
self.name = name
self.message = message
self.stackTrace = stackTrace

View File

@ -56,9 +56,9 @@ open class DefaultWebViewModel: NSObject, WebViewModel {
private func parseError(_ message: WKScriptMessage) -> WebViewError {
let body = message.body as? [String: Any]
return WebViewJSError(contentURL: body?[WebViewErrorConstants.errorUrl] as? URL,
return WebViewJSError(stringURL: body?[WebViewErrorConstants.errorUrl] as? String,
name: body?[WebViewErrorConstants.errorName] as? String,
message: body?[WebViewErrorConstants.errorMessage] as? String,
message: body?[WebViewErrorConstants.errorMessage] as? Int,
stackTrace: body?[WebViewErrorConstants.errorStack] as? String)
}
}