-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-fatal error reporter #91
Conversation
… transitions (not crashing anymore)
WalkthroughThe recent changes introduce a new error handling mechanism in the codebase. A Changes
Sequence Diagram(s)sequenceDiagram
participant Task as UBURLDataTask
participant Reporter as UBNonFatalErrorReporter
participant Handler as ErrorHandler
Task->>Task: Invalid state transition
Task->>Task: assertionFailure
Task->>Reporter: report(NSError)
Reporter->>Handler: Execute handler closure
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- Sources/UBFoundation/Logging/UBNonFatalErrorReporter.swift (1 hunks)
- Sources/UBFoundation/Networking/UBURLDataTask.swift (1 hunks)
Additional context used
SwiftLint
Sources/UBFoundation/Logging/UBNonFatalErrorReporter.swift
[Warning] 10-10: Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation (convenience_type)
Sources/UBFoundation/Networking/UBURLDataTask.swift
[Warning] 199-199: Conditional statements should always return on the next line (conditional_returns_on_newline)
[Warning] 871-871: File should contain 400 lines or less: currently contains 871 (file_length)
[Warning] 303-303: Force unwrapping should be avoided (force_unwrapping)
[Warning] 309-309: Force unwrapping should be avoided (force_unwrapping)
[Warning] 867-867: Function should have 5 parameters or less: it currently has 6 (function_parameter_count)
[Error] 80-80: Variable name 'q' should be between 3 and 40 characters long (identifier_name)
[Error] 183-183: Variable name 'r' should be between 3 and 40 characters long (identifier_name)
[Error] 557-557: Tuples should have at most 2 members (large_tuple)
[Error] 562-562: Tuples should have at most 2 members (large_tuple)
[Error] 598-598: Tuples should have at most 2 members (large_tuple)
[Error] 603-603: Tuples should have at most 2 members (large_tuple)
[Warning] 47-47: Line should be 120 characters or less; currently it has 170 characters (line_length)
[Warning] 98-98: Line should be 120 characters or less; currently it has 140 characters (line_length)
[Error] 100-100: Line should be 200 characters or less; currently it has 233 characters (line_length)
[Warning] 103-103: Line should be 120 characters or less; currently it has 164 characters (line_length)
[Warning] 105-105: Line should be 120 characters or less; currently it has 184 characters (line_length)
[Error] 107-107: Line should be 200 characters or less; currently it has 206 characters (line_length)
[Error] 108-108: Line should be 200 characters or less; currently it has 219 characters (line_length)
[Warning] 122-122: Line should be 120 characters or less; currently it has 140 characters (line_length)
[Error] 124-124: Line should be 200 characters or less; currently it has 233 characters (line_length)
[Warning] 129-129: Line should be 120 characters or less; currently it has 184 characters (line_length)
[Error] 131-131: Line should be 200 characters or less; currently it has 238 characters (line_length)
[Error] 132-132: Line should be 200 characters or less; currently it has 218 characters (line_length)
[Warning] 133-133: Line should be 120 characters or less; currently it has 152 characters (line_length)
[Warning] 201-201: Line should be 120 characters or less; currently it has 140 characters (line_length)
[Warning] 230-230: Line should be 120 characters or less; currently it has 160 characters (line_length)
[Warning] 240-240: Line should be 120 characters or less; currently it has 140 characters (line_length)
[Warning] 358-358: Line should be 120 characters or less; currently it has 175 characters (line_length)
[Warning] 363-363: Line should be 120 characters or less; currently it has 122 characters (line_length)
[Warning] 435-435: Line should be 120 characters or less; currently it has 146 characters (line_length)
[Warning] 469-469: Line should be 120 characters or less; currently it has 127 characters (line_length)
[Warning] 519-519: Line should be 120 characters or less; currently it has 144 characters (line_length)
[Warning] 521-521: Line should be 120 characters or less; currently it has 157 characters (line_length)
[Warning] 538-538: Line should be 120 characters or less; currently it has 131 characters (line_length)
[Warning] 540-540: Line should be 120 characters or less; currently it has 173 characters (line_length)
[Warning] 546-546: Line should be 120 characters or less; currently it has 165 characters (line_length)
[Warning] 557-557: Line should be 120 characters or less; currently it has 195 characters (line_length)
[Warning] 564-564: Line should be 120 characters or less; currently it has 132 characters (line_length)
[Warning] 574-574: Line should be 120 characters or less; currently it has 124 characters (line_length)
[Warning] 598-598: Line should be 120 characters or less; currently it has 163 characters (line_length)
[Warning] 605-605: Line should be 120 characters or less; currently it has 137 characters (line_length)
[Warning] 615-615: Line should be 120 characters or less; currently it has 124 characters (line_length)
[Warning] 640-640: Line should be 120 characters or less; currently it has 152 characters (line_length)
[Warning] 658-658: Line should be 120 characters or less; currently it has 178 characters (line_length)
[Warning] 659-659: Line should be 120 characters or less; currently it has 125 characters (line_length)
[Error] 678-678: Line should be 200 characters or less; currently it has 244 characters (line_length)
[Warning] 679-679: Line should be 120 characters or less; currently it has 153 characters (line_length)
[Warning] 716-716: Line should be 120 characters or less; currently it has 122 characters (line_length)
[Warning] 728-728: Line should be 120 characters or less; currently it has 122 characters (line_length)
[Warning] 738-738: Line should be 120 characters or less; currently it has 122 characters (line_length)
[Error] 754-754: Line should be 200 characters or less; currently it has 222 characters (line_length)
[Warning] 782-782: Line should be 120 characters or less; currently it has 121 characters (line_length)
[Warning] 783-783: Line should be 120 characters or less; currently it has 140 characters (line_length)
[Warning] 787-787: Line should be 120 characters or less; currently it has 133 characters (line_length)
[Warning] 812-812: Line should be 120 characters or less; currently it has 199 characters (line_length)
[Warning] 862-862: Line should be 120 characters or less; currently it has 142 characters (line_length)
[Warning] 867-867: Line should be 120 characters or less; currently it has 169 characters (line_length)
[Warning] 193-193: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 195-195: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 242-242: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 246-246: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 276-276: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 278-278: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 396-396: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 398-398: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 400-400: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 402-402: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 404-404: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 406-406: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 419-419: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 432-432: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 765-765: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 767-767: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 770-770: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Warning] 772-772: Case statements should vertically aligned with their closing brace (switch_case_alignment)
[Error] 11-11: Type body should span 350 lines or less excluding comments and whitespace: currently spans 456 lines (type_body_length)
public struct UBNonFatalErrorReporter { | ||
public static var handler: ((Error) -> Void)? | ||
|
||
static func report(_ error: Error) { | ||
handler?(error) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor UBNonFatalErrorReporter
to a caseless enum to prevent instantiation.
public enum UBNonFatalErrorReporter {
public static var handler: ((Error) -> Void)?
public static func report(_ error: Error) {
handler?(error)
}
}
Tools
SwiftLint
[Warning] 10-10: Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation (convenience_type)
let errorMessage = "Invalid state transition from \(_state) -> \(newValue)" | ||
assertionFailure(errorMessage) | ||
UBNonFatalErrorReporter.report(NSError(domain: "UBURLDataTask", code: 0, userInfo: [NSLocalizedDescriptionKey: errorMessage])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error handling by encapsulating error creation.
let errorMessage = "Invalid state transition from \(_state) -> \(newValue)"
assertionFailure(errorMessage)
UBNonFatalErrorReporter.report(createError(withMessage: errorMessage))
// Suggested helper function
private func createError(withMessage message: String) -> NSError {
return NSError(domain: "UBURLDataTask", code: 0, userInfo: [NSLocalizedDescriptionKey: message])
}
Tools
SwiftLint
[Warning] 435-435: Line should be 120 characters or less; currently it has 146 characters (line_length)
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- Sources/UBFoundation/Logging/UBNonFatalErrorReporter.swift (1 hunks)
Files skipped from review due to trivial changes (1)
- Sources/UBFoundation/Logging/UBNonFatalErrorReporter.swift
Summary by CodeRabbit
New Features
Bug Fixes
fatalError
withassertionFailure
and non-fatal error reporting to prevent app crashes during invalid state transitions.