---
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:318](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/2feab01f654eec77c6d702777ec2818472f131f1/packages/b2c-tooling-sdk/src/operations/jobs/run.ts#L318)

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}`);
}
```
