Course contentsShow
← JavaScript
Lesson 1146 of 2,72326. Error HandlingFree lesson

EvalError and URIError

Explore the rarely used EvalError and URIError types and their historical context.

EvalError and URIError

You'll learn about two rarely encountered error types that exist mainly for historical reasons and specialized edge cases.

What Are EvalError and URIError?

JavaScript includes several built-in error types, and two of them—EvalError and URIError—are like dusty old tools in a toolbox that hardly anyone uses anymore. They were designed for very specific situations that either don't happen often or were never fully implemented.

EvalError: The Error That Never Was

EvalError was originally intended to be thrown when eval() is used incorrectly. However, modern JavaScript engines never actually throw it. It exists in the specification for backward compatibility, but you'll probably never encounter one in the wild. If eval() has problems, you'll typically see a SyntaxError or TypeError instead.

Think of it as a fire extinguisher installed decades ago for a specific type of fire that turned out to never happen.

URIError: The URI Specialist

URIError is thrown when global URI-handling functions receive malformed input. These functions include encodeURI(), decodeURI(), encodeURIComponent(), and decodeURIComponent(). If you pass an invalid URI sequence (like a lone % without valid hex digits following it), you'll get a URIError.

This one is real and functional, but you'll only see it if you're working with URI encoding/decoding and something goes wrong with the input.

Why They Matter (Sort Of)

You don't need to actively use these error types in your own code. They exist primarily so JavaScript maintains consistency with older specifications and provides specificity when URI operations fail.

Key Takeaway: EvalError is a historical relic that's never actually thrown, while URIError is a specialized error for malformed URI operations—both are rarely seen in everyday JavaScript development.