---
schema_version: "1"
id: c6765052f755cf7ed5bffc001f37574e28015434190fbadbf7af99b13e172e86
title: DataSource Exceptions
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_DataSource_exceptions.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_DataSource_exceptions.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2c5f86f889fcca3e43c68ad4208e88f6da3d37c377c1680255f7ab415515864e
description: The DataSource namespace contains exception classes.
---
# DataSource Exceptions

The DataSource namespace contains exception classes.

All exception classes support built-in methods for returning the error message and exception type. See [Exception Class and Built-In Exceptions](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_exception_methods.htm "An exception denotes an error that disrupts the normal flow of code execution. You can use Apex built-in exceptions or create custom exceptions. All exceptions have common methods.").

The DataSource namespace contains these exceptions.

| Exception | Description | Methods |
| --- | --- | --- |
| DataSource.​DataSource​Exception | Throw this exception to indicate that an error occurred while communicating with an external data source. | To get the error message and write it to debug log, use the String getMessage(). |
| DataSource.OAuthTokenExpiredException | Throw this exception to indicate that an OAuth token has expired. The system then attempts to refresh the token automatically and restart the query, search, or sync operation. | To get the error message and write it to debug log, use the String getMessage(). |