How to handle errors in functions – Swift for Complete Beginners

preview_player
Показать описание
Other videos in the Functions section:

6. How to handle errors in functions: This video

Рекомендации по теме
Комментарии
Автор

I heve never seen such a easy understanding, thank a ton.

ulugbeknematjonov
Автор

Now it would be interesting to see how to combine this error handling with NSExceptions. For example if a project has a legacy Objective-C codebase, upon which new features are implemented in Swift.

BadMemoryAccess
Автор

When I saw you use !, it made me think this had something to do with how I have to handle optionals like:

let offset = keyOf)!

This works, but I'm told this is "dangerous"

So, after watching this, thought I would trying to handle it this way:


do {try offset = keyOf) }
catch{
print("Evidently keyOf doesn't exist in currentKeyNotes")
}

hmmm, that gives an error, trying to figure out how to do handle this correctly

randygloden
Автор

How common is it to use Errors in cases like this, where user enters bad password? In my experience most people just use try/catch when they need to make network requests, . Things like short passwords would just be another case in the same switch block as the happy path. Maybe nobody takes full advantage of the try/catch pattern because we don't like to think about errors :)

jaredsalzano
Автор

Hi Paul

Is there a way that I can throw an error that has a custom string? So that I don’t need an enum setup, it just reads the error message from the API

Thanks

АдамБреннан
Автор

Hi Paul,

I got an error while using \(error.localizedDescription), in the latest version of Xcode.
please help...

NavDhillon
Автор

how would you make your own localised descriptions?

breadone_
Автор

have you covered the do and catch in previous videos?

fkwhiteblackracismwarsh