> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/java/java-basics/java-data-types/others/throwable/error-vs-exception.md).

# Error vs Exception

<table data-header-hidden data-full-width="true"><thead><tr><th width="174"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Aspect</strong></td><td><strong>Error</strong></td><td><strong>Exception</strong></td></tr><tr><td><strong>Definition</strong></td><td>Represents serious problems that a reasonable application should not try to catch.</td><td>Represents conditions that an application might want to catch and handle.</td></tr><tr><td><strong>Type</strong></td><td>Subclass of <code>Throwable</code>.</td><td>Subclass of <code>Throwable</code>.</td></tr><tr><td><strong>Recoverability</strong></td><td>Non-recoverable; generally cannot be handled by the application.</td><td>Recoverable; can be caught and handled using <code>try-catch</code>.</td></tr><tr><td><strong>Examples</strong></td><td><code>OutOfMemoryError</code>, <code>StackOverflowError</code>, <code>VirtualMachineError</code>.</td><td><code>IOException</code>, <code>NullPointerException</code>, <code>ArithmeticException</code>.</td></tr><tr><td><strong>Cause</strong></td><td>Typically caused by system-level issues or resources.</td><td>Typically caused by issues in application logic or external factors.</td></tr><tr><td><strong>Handling</strong></td><td>Rarely handled as they indicate critical problems in the JVM.</td><td>Should be handled in code using <code>try-catch</code> blocks or declared using <code>throws</code>.</td></tr><tr><td><strong>When to Occur</strong></td><td>During the runtime due to system-level failures or resource exhaustion.</td><td>During compile-time (checked exceptions) or runtime (unchecked exceptions).</td></tr><tr><td><strong>Subtypes</strong></td><td>No division into checked or unchecked; all errors are unchecked.</td><td>Divided into <strong>checked</strong> (e.g., <code>IOException</code>) and <strong>unchecked</strong> (e.g., <code>NullPointerException</code>).</td></tr><tr><td><strong>Examples in Code</strong></td><td>Example: <code>throw new OutOfMemoryError();</code></td><td>Example: <code>throw new IOException("File not found");</code> or <code>throw new RuntimeException();</code>.</td></tr><tr><td><strong>Purpose</strong></td><td>Indicates issues that require JVM intervention or are fatal to the application.</td><td>Indicates issues that are part of normal application flow and can be managed.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/java/java-basics/java-data-types/others/throwable/error-vs-exception.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
