Degree Year

2022

Document Type

Thesis - Open Access

Degree Name

Bachelor of Arts

Department

Computer Science

Keywords

Error handling, Programming languages, Error, Exception, Exception handling, Defer, Compensations, Type systems, Try-catch

Abstract

Error handling is a part of nearly every computer program, but it is rarely the main focus of a program's developers. Nevertheless, correct error handling is important because it can enable a program to recover from abnormal circumstances and continue to function and serve its purpose. Programming languages offer a variety of tools and approaches for programs to detect and handle errors. I investigated the different approaches to error handling in contemporary programming languages. I found three general paradigms of error handling approaches. One paradigm was Special Return Value, in which certain return values of a function signify that an error occurred. Another paradigm was Try-Catch, where exception objects can be raised at some point in code and intercepted and handled by guards further up in the call stack. The final paradigm was Type System Approaches, in which languages used their type system to encode possible failures and ensure proper handling of these states. Besides the three main paradigms, I found several smaller or auxiliary features, such as Defer, Checked Exceptions, and Automatically Closing Resources. In addition, I compared an error handling feature originally created as an academic proposal (Compensations) with actual implementations of a similar feature in modern languages, finding that the actual implementation is more straightforward at the cost of being somewhat less powerful.

Share

COinS