TRLS010 — Use specific error type instead of base Error class
- Severity: Info
- Category: Trellis
What it detects
Flags direct construction of the base Error type, including implicit new(...), when the created type is exactly Trellis Error.
Why it matters
Specific error types such as validation, not found, and conflict are easier to match, log, and translate at boundaries.
Warning
A plain Error works, but it throws away domain meaning that Trellis error factories already encode for you.
Bad example
using Trellis;
static class Example
{
public static Result<int> Bad() =>
Result.Failure<int>(new Error("Unknown customer", "customer.not_found"));
}
Good example
using Trellis;
static class Example
{
public static Result<int> Good() =>
Result.Failure<int>(Error.NotFound("Unknown customer"));
}
Code fix available
No.
Configuration
Use standard Roslyn configuration if you need to suppress this rule in a specific scope.
dotnet_diagnostic.TRLS010.severity = none
#pragma warning disable TRLS010
// Intentional: documented exception or test-only pattern.
#pragma warning restore TRLS010
Tip
Reach for Error.Validation(...), Error.NotFound(...), Error.Conflict(...), and similar factories before constructing Error yourself.