Skip to content

Commit 2ef7c09

Browse files
authored
Update reportIssue formatting to avoid console errors (#3795)
When a non-ASCII character is fed to `reportIssue`, the following is output to the console: ``` <decode: bad range for [%@] got [offs:330 len:1073 within:0]> ``` This causes a lot of confusion for folks, so let's update the formatting to avoid this.
1 parent 5cb5b91 commit 2ef7c09

31 files changed

+344
-259
lines changed

Sources/ComposableArchitecture/Core.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ final class RootCore<Root: Reducer>: Core {
146146
if isCompleted.value {
147147
reportIssue(
148148
"""
149-
An action was sent from a completed effect:
149+
An action was sent from a completed effect.
150150
151151
Action:
152152
\(debugCaseOutput(effectAction))

Sources/ComposableArchitecture/Dependencies/Dismiss.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public struct DismissEffect: Sendable {
123123
else {
124124
reportIssue(
125125
"""
126-
A reducer requested dismissal at "\(fileID):\(line)", but couldn't be dismissed.
126+
A reducer requested dismissal at "\(fileID):\(line)", but couldn't be dismissed.
127127
128128
This is generally considered an application logic error, and can happen when a reducer \
129129
assumes it runs in a presentation context. If a reducer can run at both the root level \

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/08-RecordMeeting/ImplementingTimer-04-code-0007.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ struct RecordMeetingTests {
3030
// ❌ The store received 1 unexpected action by the end of this test: …
3131
//
3232
// Unhandled actions:
33-
// .timerTick
33+
// .timerTick
3434
}
3535
}

Sources/ComposableArchitecture/Effect.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ extension Effect {
113113
guard let handler else {
114114
reportIssue(
115115
"""
116-
An "Effect.run" returned from "\(fileID):\(line)" threw an unhandled error.
116+
An "Effect.run" returned from "\(fileID):\(line)" threw an unhandled error.
117117
118118
\(String(customDumping: error).indent(by: 4))
119119

Sources/ComposableArchitecture/Effects/TaskResult.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ extension TaskResult: Equatable where Success: Equatable {
271271
let lhsTypeName = typeName(lhsType)
272272
reportIssue(
273273
"""
274-
"\(lhsTypeName)" is not equatable.
274+
"\(lhsTypeName)" is not equatable.
275275
276276
To test two values of this type, it must conform to the "Equatable" protocol. For \
277277
example:
@@ -307,7 +307,7 @@ extension TaskResult: Hashable where Success: Hashable {
307307
let errorType = typeName(type(of: error))
308308
reportIssue(
309309
"""
310-
"\(errorType)" is not hashable.
310+
"\(errorType)" is not hashable.
311311
312312
To hash a value of this type, it must conform to the "Hashable" protocol. For example:
313313

Sources/ComposableArchitecture/Observation/Binding+Observation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extension BindingAction {
111111
}
112112
reportIssue(
113113
"""
114-
A binding action sent from a store was not handled.
114+
A binding action sent from a store was not handled.
115115
116116
Action:
117117
\(typeName(Action.self)).binding(.set(_, \(valueDump)))

Sources/ComposableArchitecture/Observation/NavigationStack+Observation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public struct _NavigationLinkStoreContent<State, Label: View>: View {
389389
"""
390390
reportIssue(
391391
"""
392-
A navigation link at "\(fileID):\(line)" is unpresentable. …
392+
A navigation link at "\(fileID):\(line)" is not presentable.
393393
394394
NavigationStack state element type:
395395
\(elementType)

Sources/ComposableArchitecture/Observation/Store+Observation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,16 +500,16 @@ extension Store where State: ObservableState {
500500

501501
func uncachedStoreWarning<State, Action>(_ store: Store<State, Action>) -> String {
502502
"""
503-
Scoping from uncached \(store) is not compatible with observation.
503+
Scoping from uncached '\(store)' is not compatible with observation.
504504
505505
This can happen for one of two reasons:
506506
507-
• A parent view scopes on a store using transform functions, which has been \
507+
1. A parent view scopes on a store using transform functions, which has been \
508508
deprecated, instead of with key paths and case paths. Read the migration guide for 1.5 \
509509
to update these scopes: \
510510
https://swiftpackageindex.com/pointfreeco/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.5
511511
512-
 A parent feature is using deprecated navigation APIs, such as 'IfLetStore', \
512+
2. A parent feature is using deprecated navigation APIs, such as 'IfLetStore', \
513513
'SwitchStore', 'ForEachStore', or any navigation view modifiers taking stores instead of \
514514
bindings. Read the migration guide for 1.7 to update those APIs: \
515515
https://swiftpackageindex.com/pointfreeco/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.7

Sources/ComposableArchitecture/Reducer/Reducers/ForEachReducer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,22 +281,22 @@ public struct _ForEachReducer<
281281
if state[keyPath: self.toElementsState][id: id] == nil {
282282
reportIssue(
283283
"""
284-
A "forEach" at "\(self.fileID):\(self.line)" received an action for a missing element.
284+
A "forEach" at "\(self.fileID):\(self.line)" received an action for a missing element.
285285
286286
Action:
287287
\(debugCaseOutput(action))
288288
289289
This is generally considered an application logic error, and can happen for a few reasons:
290290
291-
A parent reducer removed an element with this ID before this reducer ran. This reducer \
291+
A parent reducer removed an element with this ID before this reducer ran. This reducer \
292292
must run before any other reducer removes an element, which ensures that element reducers \
293293
can handle their actions while their state is still available.
294294
295-
An in-flight effect emitted this action when state contained no element at this ID. \
295+
An in-flight effect emitted this action when state contained no element at this ID. \
296296
While it may be perfectly reasonable to ignore this action, consider canceling the \
297297
associated effect before an element is removed, especially if it is a long-living effect.
298298
299-
This action was sent to the store while its state contained no element at this ID. To \
299+
This action was sent to the store while its state contained no element at this ID. To \
300300
fix this make sure that actions for this reducer can only be sent from a store when \
301301
its state contains an element at this id. In SwiftUI applications, use "ForEachStore".
302302
""",

Sources/ComposableArchitecture/Reducer/Reducers/IfCaseLetReducer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public struct _IfCaseLetReducer<Parent: Reducer, Child: Reducer>: Reducer {
215215
reportIssue(
216216
"""
217217
An "ifCaseLet" at "\(self.fileID):\(self.line)" received a child action when child state \
218-
was set to a different case.
218+
was set to a different case.
219219
220220
Action:
221221
\(String(customDumping: action).indent(by: 4))
@@ -224,16 +224,16 @@ public struct _IfCaseLetReducer<Parent: Reducer, Child: Reducer>: Reducer {
224224
225225
This is generally considered an application logic error, and can happen for a few reasons:
226226
227-
A parent reducer set "\(typeName(Parent.State.self))" to a different case before this \
227+
A parent reducer set "\(typeName(Parent.State.self))" to a different case before this \
228228
reducer ran. This reducer must run before any other reducer sets child state to a \
229229
different case. This ensures that child reducers can handle their actions while their \
230230
state is still available.
231231
232-
An in-flight effect emitted this action when child state was unavailable. While it may \
232+
An in-flight effect emitted this action when child state was unavailable. While it may \
233233
be perfectly reasonable to ignore this action, consider canceling the associated effect \
234234
before child state changes to another case, especially if it is a long-living effect.
235235
236-
This action was sent to the store while state was another case. Make sure that actions \
236+
This action was sent to the store while state was another case. Make sure that actions \
237237
for this reducer can only be sent from a store when state is set to the appropriate \
238238
case. In SwiftUI applications, use "SwitchStore".
239239
""",

0 commit comments

Comments
 (0)