---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../../modules.md) / [operations/jobs](../index.md) / getJobErrorMessage

# Function: getJobErrorMessage()

> **getJobErrorMessage**(`execution`): `string` \| `undefined`

Defined in: [packages/b2c-tooling-sdk/src/operations/jobs/run.ts:308](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/operations/jobs/run.ts#L308)

Extracts the error message from a failed job execution.

Looks for the last step execution with exit_status code 'ERROR' and returns its message.

## Parameters

### execution

The job execution to extract the error message from

## Returns

`string` \| `undefined`

The error message if found, undefined otherwise

## Example

```typescript
const errorMsg = getJobErrorMessage(execution);
if (errorMsg) {
  console.error(`Job failed: ${errorMsg}`);
}
```
