From the course: Writing Secure Code for Android by Infosec
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Exception handling, part 2
From the course: Writing Secure Code for Android by Infosec
Exception handling, part 2
- "Exception Handling Part 2." You can also have a throw expression returning nothing. This is a special type of value. Actually, it has no value. It's a special type. It indicates an unreachable block of code. You can use the nothing type in a function, and it will indicate that it will always throw an exception because it's unreachable. So here, we have some function, and it's going to return nothing, and it will always throw some kind of exception. Let's take a look at some Kotlin throw examples. We'll use the throw keyword, and we'll assign this thing called message to how do you feel. In this case, let's just say that our message length cannot be greater than 10 for whatever purpose. So if the message.length, and that means we're counting the characters here, is greater than 10, throw an illegal argument exception, "String is invalid," else, otherwise, just give us the length of the message. If we count all these characters, I can tell at a glance that it's more than 10. We means…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
System integrity8m 26s
-
(Locked)
Application integrity11m 28s
-
(Locked)
Understanding risks of embedding third-party code8m 16s
-
(Locked)
Activity: Working with external code6m 58s
-
(Locked)
Exception handling, part 16m 52s
-
(Locked)
Exception handling, part 27m 8s
-
(Locked)
Printing and logging, part 18m 53s
-
(Locked)
Printing and logging, part 29m 39s
-
(Locked)
Activity: Handling exceptions, logging and printing, part 113m 2s
-
(Locked)
Activity: Handling exceptions, logging and printing, part 211m 46s
-
(Locked)
Testing types, part 113m 57s
-
(Locked)
Testing types, part 23m 9s
-
(Locked)
Tamper protection10m 2s
-
(Locked)
Activity: Reverse engineering an Android app8m 32s
-
(Locked)
Root detection8m 45s
-
(Locked)
Social engineering6m 39s
-
(Locked)
New vulnerability research2m 36s
-
(Locked)
Secure Android coding roundup5m 19s
-
(Locked)
-