---
title: raise_error function
description: Learn the syntax of the raise\_error function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/raise_error
---

# `raise_error` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Throws an exception with `expr` as the message.

## Syntax

```
raise_error(expr)
```

## Arguments

* `expr`: A `STRING` expression.

## Returns

The `NULL` type.

The function raises a runtime error with `expr` as the error message.

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 14.2 and above

The returned error condition is [USER\_RAISED\_EXCEPTION](https://docs.databricks.com/aws/en/error-messages/error-classes.md#user_raised_exception) and the `SQLSTATE` is `P0001`.

See [Handling error conditions](https://docs.databricks.com/aws/en/error-messages/index.md#handling-error-conditions) for details on handling error conditions.

## Common error conditions

* [USER\_RAISED\_EXCEPTION](https://docs.databricks.com/aws/en/error-messages/error-classes.md#user_raised_exception)

## Examples

```sql
> SELECT raise_error('custom error message');
  Error: USER_RAISED_EXCEPTION
```

## Related functions

* [`assert_true` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/assert_true.md)
* [Handling error conditions](https://docs.databricks.com/aws/en/error-messages/index.md#handling-error-conditions)
