Skip to content

Commit

Permalink
Enable customDump only in debug mode (#3058)
Browse files Browse the repository at this point in the history
* Enable customDump only in debug mode

* Change customDump to customDumping String init
  • Loading branch information
heoblitz authored May 9, 2024
1 parent 024130d commit 1792402
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
20 changes: 8 additions & 12 deletions Sources/ComposableArchitecture/Effect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,16 @@ extension Effect {
return
} catch {
guard let handler else {
#if DEBUG
var errorDump = ""
customDump(error, to: &errorDump, indent: 4)
runtimeWarn(
"""
An "Effect.run" returned from "\(fileID):\(line)" threw an unhandled error. …
runtimeWarn(
"""
An "Effect.run" returned from "\(fileID):\(line)" threw an unhandled error. …
\(errorDump)
\(String(customDumping: error).indent(by: 4))
All non-cancellation errors must be explicitly handled via the "catch" parameter \
on "Effect.run", or via a "do" block.
"""
)
#endif
All non-cancellation errors must be explicitly handled via the "catch" parameter \
on "Effect.run", or via a "do" block.
"""
)
return
}
await handler(error, send)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,15 @@ public struct _IfCaseLetReducer<Parent: Reducer, Child: Reducer>: Reducer {
guard let childAction = self.toChildAction.extract(from: action)
else { return .none }
guard var childState = self.toChildState.extract(from: state) else {
var actionDump = ""
customDump(action, to: &actionDump, indent: 4)
var stateDump = ""
customDump(state, to: &stateDump, indent: 4)
runtimeWarn(
"""
An "ifCaseLet" at "\(self.fileID):\(self.line)" received a child action when child state \
was set to a different case. …
Action:
\(actionDump)
\(String(customDumping: action).indent(by: 4))
State:
\(stateDump)
\(String(customDumping: state).indent(by: 4))
This is generally considered an application logic error, and can happen for a few reasons:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,13 @@ public struct _IfLetReducer<Parent: Reducer, Child: Reducer>: Reducer {
guard let childAction = self.toChildAction.extract(from: action)
else { return .none }
guard state[keyPath: self.toChildState] != nil else {
var actionDump = ""
customDump(action, to: &actionDump, indent: 4)
runtimeWarn(
"""
An "ifLet" at "\(self.fileID):\(self.line)" received a child action when child state was \
"nil". …
Action:
\(actionDump)
\(String(customDumping: action).indent(by: 4))
This is generally considered an application logic error, and can happen for a few reasons:
Expand Down

0 comments on commit 1792402

Please sign in to comment.