Upload
cocoaheads-france
View
231
Download
0
Embed Size (px)
Citation preview
@kamidude
STOPPING EXECUTION
objc can @catch exceptions / swift cannot only fatalError is kept on -Ounchecked
*
@kamidude
SWIFT ERRORSbasics - catching errors
catch can match pattern swift errors are not exceptions !
*
@kamidude
ERRORShandling strategies
My own rules of thumb Adapt to your use case
Expected Unexpected
Domain• Handle in the application code • Display details to the user • Don’t log the error
• Raise an error • Display details to the user • Log the error
Technical• Handle in the application code • Don’t display details to the user • Don’t log the error
• Raise an error • Don’t display details to the user • Log the error
Domain vs Technical / Expected vs Unexpected
http://www.blueskyline.com/ErrorPatterns/ErrorPatternsPaper.pdf
@kamidude
ERRORSerror semantic - handling strategies
Retry Silently
- Not a solution : if the retry fails, you have to handle the error eventually
- Exponential backoff
👍 Easy 👎 Not a real solution
My own rules of thumb Adapt to your use case
@kamidude
ERRORSerror semantic - handling strategies
Ask user to retry / cancel
- Modally or not - Basic strategy : prevent access to content
👍 Easy 👎 Poor UX
My own rules of thumb Adapt to your use case
@kamidude
ERRORSerror semantic - handling strategies
Optimistic update
- Show updated local UI - Works for user actions, not fetching
👍 User friendly / works in most cases 👎 Involves complex synchronization / client logic
My own rules of thumb Adapt to your use case
@kamidude
ERRORSerror semantic - handling strategies
Crash
- Intended or not
👍 Get info through CrashReporter & fix 👎 Not very user friendly
My own rules of thumb Adapt to your use case