Skip to content
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

Feature request: No calls to fatalError in production code #537

Closed
berikv opened this issue Aug 30, 2018 · 1 comment · May be fixed by #538
Closed

Feature request: No calls to fatalError in production code #537

berikv opened this issue Aug 30, 2018 · 1 comment · May be fixed by #538
Labels

Comments

@berikv
Copy link

berikv commented Aug 30, 2018

New Issue Checklist

  • [✅] I have looked at the Documentation
  • [✅] I have read the F.A.Q.
  • [✅] I have filled out this issue template.

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 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.

@berikv 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 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
@robertjpayne
Copy link
Member

robertjpayne commented Sep 18, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants