Learn how to flag and process error states by raising and handling exceptions.
- [Narrator] Now if you're paying attention…in the last clip, you'll have noticed…that prompt actually isn't an ideal function…if you give it wacky values.…Let's try prompt minus one.…There are minus one items,…well does that make any sense at all?…So maybe we want to do some exception handling…to protect this function against out of range values.…So we're going to do an imperative if,…in other words an if without a then,…because we don't actually need to do anything else.…I'm going to raise an argument,…so that's a completely normal dot net exception…with the message value can't be less than naught.…
So that's all you need to do to raise an exception,…so just try that out.…Let's go down the happy part first…with prompt2 of one.…That's fine.…By the way I forgot to change the printf n again,…so let us fix that.…Perfect.…And what happens now if we hit it with minus one.…Argument exceptional, though that looks ugly…that's exactly what we wanted to happen.…And by the way, later in the course…we'll be looking at much more elegant ways…
- Defining values and calling functions in F#
- Defining and identifying discriminated unions
- Working with if-else expressions
- Writing unit test
- Using type providers to access data
- Analyzing data with collection functions
- Plotting data using the R type provider
- Using railway-oriented programming to handle errors
- Integrating with Twitter
- Deploying an F# application to Azure
Skill Level Intermediate
1. Get Started with F#
2. Build a Simple Parser with Unit Testing
3. Use F# CSV Type Provider to Get Data
4. Analyze Data with F# Collection Functions
5. Use RStats Provider and ggplot2 to Plot Data
6. Use BoxKite with Twitter
7. Deploy a Working Bot
Next steps1m 46s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.