> For the complete documentation index, see [llms.txt](https://george-jen.gitbook.io/data-science-and-apache-spark/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://george-jen.gitbook.io/data-science-and-apache-spark/scala-exceptions-+-try-catch-finally.md).

# Scala Exceptions + try catch finally

Example:

```
try
    { 
        // Dividing by zero 
        val result = 11/0
    } 
      
    // Catch clause 
    catch
    {  
            // Case statement 
            case x: ArithmeticException => 
            {  
          
            // Display this if exception is found 
            println("Exception: A number is not divisible by zero.") 
        } 
    }
    finally
    {
        println("This is how try catch finally works")
    }
    
    /*
    Exception: A number is not divisible by zero.
    This is how try catch finally works
    */


```
