Skip to content

Commit 044ce9b

Browse files
committed
Hash JSON info on prod
1 parent 90886c8 commit 044ce9b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ let package = Package(
2424
dependencies: [
2525
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
2626
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
27+
],
28+
swiftSettings: [
29+
.define("DEBUG", .when(configuration: .debug))
2730
]
2831
),
2932
// Targets are the basic building blocks of a package, defining a module or a test suite.

Sources/DSBridge/Error/Error.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public extension LoggableError {
2222
}
2323

2424
public enum Error {
25-
25+
static var hash: String = "*hashed*"
26+
static var hashObject = Hash()
27+
struct Hash { }
2628
}
2729

2830
extension Error {
@@ -38,7 +40,11 @@ extension Error.JSON {
3840
public var debugDescription: String {
3941
switch self {
4042
case .invalidCallingFromJS(let string):
43+
#if DEBUG
4144
"JS called with invalid parameters: \(string)"
45+
#else
46+
"JS called with invalid parameters: \(Error.hash)"
47+
#endif
4248
case .underlyingJSONSerialization(let error):
4349
"Error from JSONSerialization: \(error)"
4450
}
@@ -56,11 +62,19 @@ extension Error.JSON {
5662
public var debugDescription: String {
5763
switch self {
5864
case .failedToEncode(let object):
65+
#if DEBUG
5966
"Failed to encode JSON data into UTF-8 text: \(object)"
67+
#else
68+
"Failed to encode JSON data into UTF-8 text: \(Error.hashObject)"
69+
#endif
6070
case .underlyingJSONEncoding(let error):
6171
"Error from JSONEncoder: \(error)"
6272
case .invalidJSONObject(let object):
73+
#if DEBUG
6374
"Object is not a valid JSON object: \(object)"
75+
#else
76+
"Object is not a valid JSON object: \(Error.hashObject)"
77+
#endif
6478
}
6579
}
6680

0 commit comments

Comments
 (0)