Skip to content

use-standard-error

Id
@azure-tools/typespec-azure-resource-manager/use-standard-error

Non-HEAD operations must define a response marked with @error and use ErrorResponse from ARM common types for marked error payloads.

Use standard ARM operation templates and their default Azure.ResourceManager.CommonTypes.ErrorResponse error type.

This rule checks all operations except HEAD for at least one response model marked with TypeSpec’s @error decorator. Every @error response’s payload must reference the standard Azure.ResourceManager.CommonTypes.ErrorResponse model.

Error bodies must use the standard model directly, including through aliases or an explicit @body property.

  • Area: API design and generated SDKs

Using one standard error contract gives generated SDKs and Azure tooling a consistent error shape across operations.

Suppress only when required to match an existing API; otherwise use Azure.ResourceManager.CommonTypes.ErrorResponse for operation error payloads.

@error
model CustomError {
code: string;
message: string;
}
@armResourceOperations
interface Widgets {
restart is ArmResourceActionAsync<Widget, void, void, Error = CustomError>;
}
@armResourceOperations
interface Widgets {
restart is ArmResourceActionAsync<Widget, void, void>;
}

ArmResourceActionAsync uses the standard ErrorResponse by default.

This rule promotes the LintDiff migration of the Swagger validator rule LroErrorContent.