Skip to main content

Questions tagged [error-handling]

Use this tag for questions about handling errors in a programming language at compile-time or how to manage them at runtime. Do not use this tag for general programming error handling questions.

Filter by
Sorted by
Tagged with
7 votes
5 answers
1k views

Exception handling: is one exception type sufficient?

(This question is somewhat related to Exception handling: 'catch' without explicit 'try') Context I'm working on a new general-purpose programming language. Exception handling is ...
Thomas Mueller's user avatar
4 votes
5 answers
1k views

Exception handling: 'catch' without explicit 'try'

(I was not aware of this site and asked, by mistake, a similar question on cs.stackexchange as well. It is related to this question on this site.) Context I'm working on a new general-purpose ...
Thomas Mueller's user avatar
13 votes
2 answers
661 views

How to tolerate syntax errors in a typed language?

In my tokenizers and parsers, once I find a syntax error (like an unexpected token) I usually throw a fatal exception that finishes parsing of the input source. The downside of how I usually do it is ...
Hydroper's user avatar
  • 1,027
14 votes
12 answers
7k views

Can sine converge to zero at infinity?

In common languages, sine produces an error, NaN, or exception when evaluated at infinity. For example, in Python: ...
Corbin's user avatar
  • 851
4 votes
4 answers
434 views

What goes wrong when division-by-zero is defined as multiplication-by-infinity?

Sometimes, we want to implement floating-point operations on systems which use IEEE 754 representations of values, but don't necessarily support IEEE 754 semantics. For example, we may be using the <...
Corbin's user avatar
  • 851
5 votes
1 answer
238 views

What sort of "syntax error recovery" is possible for this indentation based language?

I am thinking of how to write the parser/compiler so it works as a VSCode Language Server Extension, so I can have it show syntax errors, do autocomplete, and other things, in VSCode. One thing that I'...
Lance Pollard's user avatar
12 votes
4 answers
2k views

Why would a language have different error handling for libraries and applications?

Rust has two popular packages for augmenting its error handling: anyhow, for libraries, created by David Tolnay. thiserror, for applications, created by David Tolnay. They control how errors are ...
BoppreH's user avatar
  • 1,451
3 votes
1 answer
188 views

What are the pros and cons of showing multiple parse errors at once?

The alternative to showing multiple parse errors at once is to display and handle each error individually as they are encountered during the parsing process, which I would presume is simpler to ...
Starship's user avatar
  • 1,356
8 votes
1 answer
254 views

In a language with explicit error handling, how to reduce boilerplate for common fallible operations?

Many languages prioritize runtime safety by forcing users to handle (or annotate) the error cases for operations that can fail. This works well for I/O and complex algorithms, but how should common ...
BoppreH's user avatar
  • 1,451
18 votes
5 answers
3k views

What should be included in error messages?

New users of a language will spend a lot of their time staring at error messages, and realistically so will the language designers. These messages should be an early consideration, given that adding ...
BoppreH's user avatar
  • 1,451
21 votes
6 answers
3k views

How does one transpile valid code that corresponds to undefined behavior in the target language?

Consider the following C# snippet: Object bad= null; Console.WriteLine(bad.ToString()); This is valid C#. It will raise a ...
Robert Columbia's user avatar
4 votes
1 answer
205 views

Languages that compile to Lua bytecode (.luac) for including source locations?

The most popular language that transpiles to Lua is MoonScript. One problem with the MoonScript's compiler is that when a runtime error occurs on e.g. a table access the diagnostic source location is ...
Hydroper's user avatar
  • 1,027
13 votes
8 answers
1k views

Pros and cons of throwing an error versus returning a NaN value

So I've seen that many languages return a NaN value when calculating an indeterminate arithmetic expression (e.g. 0/0). Other ...
The Empty String Photographer's user avatar
13 votes
2 answers
203 views

What ways are there to determine if cascading compile errors are dependent or independent?

In my experience as a developer, a single syntax error made in a long program can result in a long cascading list of error messages, only the first of which is directly relevant to the solution. For ...
Robert Columbia's user avatar
17 votes
5 answers
2k views

Are very explanatory compiler error messages worth the effort needed to implement them?

This question is related to, but not the same as, What are some ways of reporting compilation errors? as that questions gets into the design of handling compiler errors at the compiler level (and the ...
Spevacus's user avatar
  • 615
34 votes
9 answers
4k views

Why would a language have a concept of undefined behavior instead of raising an error?

Certain constructs or conditions in programming just are not allowed. Languages such as Java or Swift handle these by raising an error when encountered. C and C++ on the other hand say 'Anything could ...
CPlus's user avatar
  • 9,143
7 votes
1 answer
455 views

How to report multiple compilation errors?

What are some good ways to report errors when compiling code in a new programming language? One answer may be to just stop after the first error, but this can be unsatisfactory because it takes ...
Isaiah's user avatar
  • 808
47 votes
13 answers
2k views

What are different ways of handling runtime errors?

Most languages have a system where exceptions are classes and you can throw them then use a try/catch block to handle them. What ...
mousetail 'he-him''s user avatar