# assert

[**utils**](/near-sdk-js/utils.md) • **Docs**

***

[near-sdk-js v2.0.0](/near-sdk-js/packages.md) / [utils](/near-sdk-js/utils.md) / assert

## Function: assert()

> **assert**(`expression`, `message`): `asserts expression`

Asserts that the expression passed to the function is truthy, otherwise throws a new Error with the provided message.

### Parameters

• **expression**: `unknown`

The expression to be asserted.

• **message**: `string`

The error message to be printed.

### Returns

`asserts expression`

### Defined in

[packages/near-sdk-js/src/utils.ts:58](https://github.com/near/near-sdk-js/blob/b58ac04fc6dff2f1120e9098c0cb059493486598/packages/near-sdk-js/src/utils.ts#L58)


---

# Agent Instructions: 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:

```
GET https://near-sdk-js.gitbook.io/near-sdk-js/utils/functions/assert.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
