You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SnapKit validates its inputs and when an error is detected it calls fatalError.
Calling fatalError makes it easy to discover an issue while developing, but when the code is in production a call to fatalError causes a crash for an end-user. This can cause a recoverable application error to become an unavoidable crash.
Suggested Implementation
Create an Error type that (is part of or) extends ConstraintDescription and captures error information.
Instantiate and return the Error type instead of calling fatalError when an input validation error occurs.
Add a custom error handler to ConstraintMaker.
In endMakingConstraints call the custom error handler passing the errors that have occurred when it is set. If the custom error handler is not set, call fatalError with the joined list of error descriptions.
I have not yet researched the overall impact of this suggestion on SnapKit's source code and I am looking for feedback before attempting an implementation.
The text was updated successfully, but these errors were encountered:
berikv
changed the title
Feature request: No calls to fatalError called in production builds
Feature request: No calls to fatalError in production builds
Aug 30, 2018
berikv
changed the title
Feature request: No calls to fatalError in production builds
Feature request: No calls to fatalError in production code
Aug 30, 2018
The purpose of fatal errors is because these errors are actually fatal and not resolvable. They should not be happening under normal circumstances as it means you've incorrectly used the auto layout API's and therefore should be corrected during testing and not be silenced via try/catch handlers.
New Issue Checklist
Issue Description
SnapKit validates its inputs and when an error is detected it calls
fatalError
.Calling
fatalError
makes it easy to discover an issue while developing, but when the code is in production a call tofatalError
causes a crash for an end-user. This can cause a recoverable application error to become an unavoidable crash.Suggested Implementation
Create an Error type that (is part of or) extends
ConstraintDescription
and captures error information.Instantiate and return the Error type instead of calling
fatalError
when an input validation error occurs.Add a custom error handler to
ConstraintMaker
.In
endMakingConstraints
call the custom error handler passing the errors that have occurred when it is set. If the custom error handler is not set, callfatalError
with the joined list of error descriptions.I have not yet researched the overall impact of this suggestion on SnapKit's source code and I am looking for feedback before attempting an implementation.
The text was updated successfully, but these errors were encountered: