> For the complete documentation index, see [llms.txt](https://yams.yassrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yams.yassrobotics.com/api-reference/java-reference/exceptions.md).

# Exceptions

Package: `yams.core.exceptions`\
Javadoc: [`yams.core.exceptions`](https://javadocs.yassrobotics.com/yams/yams/core/exceptions/package-summary.html)

YAMS throws typed `RuntimeException` subclasses for configuration and runtime errors. All exceptions extend `RuntimeException` so they are unchecked; you do not need to declare or catch them unless you want to handle configuration problems gracefully.

Most exceptions are thrown during motor controller or mechanism construction if required configuration fields are missing.

***

## Exception classes

| Class                                         | Thrown When                                                                            |
| --------------------------------------------- | -------------------------------------------------------------------------------------- |
| `ArmConfigurationException`                   | Required `ArmConfig` fields are missing or invalid                                     |
| `DifferentialMechanismConfigurationException` | Required `DifferentialMechanismConfig` fields are missing                              |
| `DoubleJointedArmConfigurationException`      | A joint `ArmConfig` is missing required fields                                         |
| `ElevatorConfigurationException`              | Required `ElevatorConfig` fields are missing                                           |
| `FlyWheelConfigurationException`              | Required `FlyWheelConfig` fields are missing                                           |
| `PivotConfigurationException`                 | Required `PivotConfig` fields are missing                                              |
| `SmartMotorControllerConfigurationException`  | The `SmartMotorControllerConfig` is invalid or missing required options                |
| `SwerveDriveConfigurationException`           | Required `SwerveDriveConfig` fields are missing                                        |
| `MotorNotPresentException`                    | A mechanism has no motor controller (defined, but not currently thrown by YAMS itself) |
| `InvalidStageGivenException`                  | A gear stage string is not in `"IN:OUT"` format                                        |
| `NoStagesGivenException`                      | A `GearBox` or `Sprocket` was constructed with an empty stage list                     |

***

## Configuration exception constructors

Most configuration exceptions follow this constructor pattern:

```java
SomeConfigurationException(String message, String result, String remedyFunction)
```

| Parameter        | Description                                             |
| ---------------- | ------------------------------------------------------- |
| `message`        | Description of what is missing or invalid               |
| `result`         | What behavior will be broken without this configuration |
| `remedyFunction` | The builder method to call to fix the problem           |

The remaining exceptions take simpler arguments:

```java
MotorNotPresentException(String mechanismType)
InvalidStageGivenException(String stage)
NoStagesGivenException()
```

***

## Example error handling

```java
try {
    SmartMotorController motor = new SparkWrapper(
        new SparkMax(CANPort.CAN_S0, 1, MotorType.kBrushless),
        DCMotor.getNEO(1),
        config
    );
} catch (SmartMotorControllerConfigurationException e) {
    DriverStation.reportError("Motor config error: " + e.getMessage(), false);
}
```

{% hint style="info" %}
Leave these exceptions uncaught: the stack trace names the config method you need to call. Catching one doesn't keep the robot working. It means the motor controller or mechanism was never built, so the code fails the first time it uses it instead. Fix the config before an event, and catch the exception only to log its message.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://yams.yassrobotics.com/api-reference/java-reference/exceptions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
