# Source
{: .no_toc }

Returns or sets a **String** specifying the name of the object or application that originally generated the error. Read/write.

Syntax:
- **Err**.**Source**
- **Err**.**Source** **=** *errorSource*

*errorSource*
: A **String** identifying the source of the error. When read, **Source** returns the source for the active error, or a zero-length string if no error is active.

The **Source** property holds a string representing the object that generated the error; the expression is usually the object's class name or programmatic ID.

Use **Source** to provide information when handling code cannot handle an error generated in an accessed object. For example, when a call into an Automation server raises a `Division by zero` error, the server sets **Err.Number** to its error code for that error and sets **Source** to its programmatic ID.

When generating an error from user code, pass the source to [**Raise**](/tB/Modules/ErrObject/Raise.md). For class modules, **Source** should contain a name in the form *project.class*. Without a source argument, **Source** is an empty string.

When an error occurs that twinBASIC raises itself, such as a division by zero, **Source** is an empty string too, in a standard module and in a class module alike.

> [!WARNING] BETA 1045
> It does not fill in **Source**, and raises no error. VBA and VB6 fill it in automatically with the name of the project, for an error that the runtime raises and for **Raise** without a source argument. A program that reads **Err.Source** to find where an error came from gets an empty string.

### Common Errors

| Error | When |
|---|---|
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *errorSource* is **Null** |

### Example

This example assigns the programmatic ID of an Automation object to the variable `myObjectID`, and then assigns that to the **Source** property of the **Err** object when it generates an error with the [**Raise**](/tB/Modules/ErrObject/Raise.md) method.

When handling errors, do not rely on the **Source** property (or any **Err** properties other than [**Number**](/tB/Modules/ErrObject/Number.md)) for control flow. The intended use of properties other than **Number** is to display detailed information to an end user when an error cannot be handled.

```tb check_build
Dim myObjectID As String, myHelpFile As String, myHelpContext As Long
myObjectID = "MyApp.MyClass"
Err.Raise Number:=vbObjectError + 894, Source:=myObjectID, _
          Description:="Was not able to complete your task", _
          HelpFile:=myHelpFile, HelpContext:=myHelpContext
```

### See Also

- [Number](/tB/Modules/ErrObject/Number.md) property
- [Description](/tB/Modules/ErrObject/Description.md) property
- [Raise](/tB/Modules/ErrObject/Raise.md) method
- [Clear](/tB/Modules/ErrObject/Clear.md) method
