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…
Author
Released
12/20/2016- 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
Duration
Views
Related Courses
-
Visual Studio Essential Training: 05 Code Editors
with Walt Ritscher3h 25m Intermediate
-
Introduction
-
Welcome59s
-
Exercise files41s
-
-
1. Get Started with F#
-
Record type and arrays2m 35s
-
Forward piping3m 39s
-
Array mapping and iteration6m 22s
-
If-else expressions2m 9s
-
Exception handling2m 40s
-
Option types5m 9s
-
The bot and type signatures4m 19s
-
2. Build a Simple Parser with Unit Testing
-
Install NUnit4m 23s
-
Write a real test4m 31s
-
Write a parser5m 8s
-
Refactor tests5m 18s
-
Test unhappy paths4m 1s
-
Challenge35s
-
Solution3m 38s
-
3. Use F# CSV Type Provider to Get Data
-
Recap and code tidy-up1m 51s
-
Introducing Quandl1m 52s
-
Challenge1m 14s
-
Solution9m 34s
-
-
4. Analyze Data with F# Collection Functions
-
5. Use RStats Provider and ggplot2 to Plot Data
-
RStats and ggplot21m 38s
-
Develop the chart generator5m 45s
-
Challenge38s
-
Solution2m 21s
-
-
6. Use BoxKite with Twitter
-
Create a Twitter application5m 24s
-
React to directed tweets4m 47s
-
-
7. Deploy a Working Bot
-
Call the reply function1m 17s
-
Try the bot running locally1m 53s
-
Understanding ROP2m 37s
-
Conclusion
-
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?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake 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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Exception handling