# DurableTaskRejectedException Constructors

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskrejectedexception/)

## DurableTaskRejectedException(TaskId, GrainId, string?, string) {#constructor-orleans-durable-tasks-taskid-orleans-runtime-grainid-string-nullable-d6d95b0a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.tasks.durabletaskrejectedexception/constructors/constructor-orleans-durable-tasks-taskid-orleans-runtime-grainid-string-nullable-d6d95b0a/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableTasks/DurableTaskRejectedException.cs#L33-L40)

```csharp
public DurableTaskRejectedException(TaskId taskId, GrainId target, string? code, string reason)
```

Initializes an exception for the rejected invocation of `taskId` on `target`.

### Parameters

- `taskId` (`TaskId`): The task which the invocation starts.
- `target` (`GrainId`): The grain which rejected the invocation.
- `code` (`string?`): The rejection code which the grain reported, or `null` for none.
- `reason` (`string`): The grain's reason.
