@ozerohax/assistagents 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/cli.js +442 -0
- package/dist/cli.js.map +1 -0
- package/package.json +39 -0
- package/templates/agents/ask/ask.md +126 -0
- package/templates/agents/assist/research/code-research.md +116 -0
- package/templates/agents/assist/research/web-research.md +105 -0
- package/templates/agents/build/dev.md +131 -0
- package/templates/agents/planning/plan.md +103 -0
- package/templates/agents/planning/project.md +122 -0
- package/templates/agents/review/reviewer.md +121 -0
- package/templates/agents/test/tester.md +170 -0
- package/templates/skills/coder/csharp/coder-csharp-aspnetcore-api/SKILL.md +352 -0
- package/templates/skills/coder/csharp/coder-csharp-async-concurrency/SKILL.md +63 -0
- package/templates/skills/coder/csharp/coder-csharp-conventions/SKILL.md +405 -0
- package/templates/skills/coder/csharp/coder-csharp-efcore-config/SKILL.md +384 -0
- package/templates/skills/coder/csharp/coder-csharp-efcore-queries/SKILL.md +434 -0
- package/templates/skills/coder/csharp/coder-csharp-error-handling/SKILL.md +354 -0
- package/templates/skills/coder/csharp/coder-csharp-logging/SKILL.md +362 -0
- package/templates/skills/coder/csharp/coder-csharp-performance/SKILL.md +71 -0
- package/templates/skills/coder/csharp/coder-csharp-security/SKILL.md +57 -0
- package/templates/skills/coder/csharp/coder-csharp-testing/SKILL.md +398 -0
- package/templates/skills/coder/rust/coder-rust-async-concurrency/SKILL.md +63 -0
- package/templates/skills/coder/rust/coder-rust-axum-api/SKILL.md +104 -0
- package/templates/skills/coder/rust/coder-rust-conventions/SKILL.md +57 -0
- package/templates/skills/coder/rust/coder-rust-error-handling/SKILL.md +56 -0
- package/templates/skills/coder/rust/coder-rust-logging/SKILL.md +69 -0
- package/templates/skills/coder/rust/coder-rust-performance/SKILL.md +51 -0
- package/templates/skills/coder/rust/coder-rust-security/SKILL.md +49 -0
- package/templates/skills/coder/rust/coder-rust-serde/SKILL.md +61 -0
- package/templates/skills/coder/rust/coder-rust-sqlx-config/SKILL.md +54 -0
- package/templates/skills/coder/rust/coder-rust-sqlx-queries/SKILL.md +66 -0
- package/templates/skills/coder/rust/coder-rust-testing/SKILL.md +52 -0
- package/templates/skills/coder/rust/coder-rust-tokio/SKILL.md +69 -0
- package/templates/skills/coder/rust/coder-rust-tower-http/SKILL.md +56 -0
- package/templates/skills/coder/typescript/coder-typescript-async-concurrency/SKILL.md +73 -0
- package/templates/skills/coder/typescript/coder-typescript-conventions/SKILL.md +156 -0
- package/templates/skills/coder/typescript/coder-typescript-error-handling/SKILL.md +126 -0
- package/templates/skills/coder/typescript/coder-typescript-logging/SKILL.md +107 -0
- package/templates/skills/coder/typescript/coder-typescript-performance/SKILL.md +83 -0
- package/templates/skills/coder/typescript/coder-typescript-security/SKILL.md +78 -0
- package/templates/skills/coder/typescript/coder-typescript-testing/SKILL.md +111 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-composables/SKILL.md +57 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-core/SKILL.md +65 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-performance/SKILL.md +48 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-primevue/SKILL.md +140 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-primevue/scripts/primevue-docs.js +502 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-reactivity/SKILL.md +61 -0
- package/templates/skills/coder/typescript/coder-typescript-vuejs/coder-typescript-vuejs-testing/SKILL.md +63 -0
- package/templates/skills/planning/code/planning-code-feature/SKILL.md +148 -0
- package/templates/skills/planning/code/planning-code-fix/SKILL.md +207 -0
- package/templates/skills/planning/project/fast/planning-project-fast-delivery-deploy/SKILL.md +33 -0
- package/templates/skills/planning/project/fast/planning-project-fast-intake-questions/SKILL.md +82 -0
- package/templates/skills/planning/project/fast/planning-project-fast-mvp-slicing/SKILL.md +36 -0
- package/templates/skills/planning/project/fast/planning-project-fast-output-template/SKILL.md +79 -0
- package/templates/skills/planning/project/fast/planning-project-fast-session-plan/SKILL.md +30 -0
- package/templates/skills/planning/project/shared/planning-project-acceptance-criteria/SKILL.md +46 -0
- package/templates/skills/planning/project/shared/planning-project-artifact-storage/SKILL.md +68 -0
- package/templates/skills/planning/project/shared/planning-project-checkpoints-approval/SKILL.md +24 -0
- package/templates/skills/planning/project/shared/planning-project-save-revision/SKILL.md +33 -0
- package/templates/skills/planning/project/shared/planning-project-scope-control/SKILL.md +30 -0
- package/templates/skills/planning/project/shared/planning-project-success-metric-scope/SKILL.md +41 -0
- package/templates/skills/planning/project/shared/planning-project-task-decomposition/SKILL.md +47 -0
- package/templates/skills/planning/project/shared/planning-project-testing-validation/SKILL.md +31 -0
- package/templates/skills/planning/project/standard/planning-project-standard-architecture-adr-lite/SKILL.md +68 -0
- package/templates/skills/planning/project/standard/planning-project-standard-epics-stories/SKILL.md +41 -0
- package/templates/skills/planning/project/standard/planning-project-standard-implementation-readiness-lite/SKILL.md +32 -0
- package/templates/skills/planning/project/standard/planning-project-standard-prd-fr-nfr/SKILL.md +60 -0
- package/templates/skills/planning/project/standard/planning-project-standard-product-brief/SKILL.md +46 -0
- package/templates/skills/planning/project/standard/planning-project-standard-story-to-tasks/SKILL.md +52 -0
- package/templates/skills/research-strategy/research-strategy-code/SKILL.md +80 -0
- package/templates/skills/research-strategy/research-strategy-web/SKILL.md +63 -0
- package/templates/skills/review/review-checklists/SKILL.md +57 -0
- package/templates/skills/review/review-requirements/SKILL.md +42 -0
- package/templates/skills/review/review-strategy/SKILL.md +120 -0
- package/templates/skills/testing/testing-api-manual/SKILL.md +535 -0
- package/templates/skills/testing/testing-automation-web/SKILL.md +81 -0
- package/templates/skills/testing/testing-browser-manual/SKILL.md +528 -0
- package/templates/skills/testing/testing-checklists/SKILL.md +434 -0
- package/templates/skills/testing/testing-strategy/SKILL.md +471 -0
- package/templates/skills/testing/testing-test-cases/SKILL.md +362 -0
- package/templates/skills/testing/testing-triage-bugs/SKILL.md +457 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: coder-csharp-error-handling
|
|
3
|
+
description: C# error handling, validation, and Result pattern best practices. Use when handling exceptions, implementing validation, designing error responses, or choosing between exceptions and Result types.
|
|
4
|
+
---
|
|
5
|
+
<skill_overview>
|
|
6
|
+
<purpose>Implement robust error handling following modern .NET patterns</purpose>
|
|
7
|
+
<triggers>
|
|
8
|
+
<trigger>Handling exceptions in services</trigger>
|
|
9
|
+
<trigger>Implementing validation logic</trigger>
|
|
10
|
+
<trigger>Designing API error responses</trigger>
|
|
11
|
+
<trigger>Choosing Result pattern vs exceptions</trigger>
|
|
12
|
+
<trigger>Setting up global exception handling</trigger>
|
|
13
|
+
</triggers>
|
|
14
|
+
<sources>
|
|
15
|
+
<source url="https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/exceptions/">Microsoft Exception Handling</source>
|
|
16
|
+
</sources>
|
|
17
|
+
</skill_overview>
|
|
18
|
+
<exceptions_vs_result>
|
|
19
|
+
<use_exceptions_when>
|
|
20
|
+
<case>Truly exceptional, unexpected failures</case>
|
|
21
|
+
<case>System-level errors (I/O, network, hardware)</case>
|
|
22
|
+
<case>In constructors (can't return Result)</case>
|
|
23
|
+
<case>Framework boundaries expecting exceptions</case>
|
|
24
|
+
<case>Programming errors (null, out of range)</case>
|
|
25
|
+
</use_exceptions_when>
|
|
26
|
+
<use_result_when>
|
|
27
|
+
<case>Expected business failures (validation, not found)</case>
|
|
28
|
+
<case>Multiple possible failure modes</case>
|
|
29
|
+
<case>Performance-critical hot paths</case>
|
|
30
|
+
<case>Domain layer business logic</case>
|
|
31
|
+
<case>Compile-time safety for error handling</case>
|
|
32
|
+
</use_result_when>
|
|
33
|
+
<example_comparison>
|
|
34
|
+
<code>
|
|
35
|
+
// Exception: Unexpected failure
|
|
36
|
+
if (connection == null)
|
|
37
|
+
throw new InvalidOperationException("Connection not initialized");
|
|
38
|
+
// Result: Expected business outcome
|
|
39
|
+
public Result<User> GetUser(int id)
|
|
40
|
+
{
|
|
41
|
+
var user = _repository.Find(id);
|
|
42
|
+
if (user == null)
|
|
43
|
+
return Result.Fail("User not found"); // Expected case
|
|
44
|
+
return Result.Ok(user);
|
|
45
|
+
}
|
|
46
|
+
</code>
|
|
47
|
+
</example_comparison>
|
|
48
|
+
</exceptions_vs_result>
|
|
49
|
+
<exception_best_practices>
|
|
50
|
+
<throwing>
|
|
51
|
+
<rule>Throw for truly exceptional conditions only</rule>
|
|
52
|
+
<rule>Use specific exception types</rule>
|
|
53
|
+
<rule>Include context in exception message</rule>
|
|
54
|
+
<example>
|
|
55
|
+
<code>
|
|
56
|
+
// Good: Specific exception with context
|
|
57
|
+
throw new ArgumentNullException(nameof(email), "Email is required for user creation");
|
|
58
|
+
// Good: Use built-in guard methods (.NET 6+)
|
|
59
|
+
ArgumentNullException.ThrowIfNull(user);
|
|
60
|
+
ArgumentException.ThrowIfNullOrEmpty(email);
|
|
61
|
+
// Bad: Generic exception
|
|
62
|
+
throw new Exception("Error occurred");
|
|
63
|
+
</code>
|
|
64
|
+
</example>
|
|
65
|
+
</throwing>
|
|
66
|
+
<catching>
|
|
67
|
+
<rule>Catch specific exceptions first, general last</rule>
|
|
68
|
+
<rule>Use exception filters (when clause) for fine-grained control</rule>
|
|
69
|
+
<rule>Always use "throw;" not "throw ex;" to preserve stack trace</rule>
|
|
70
|
+
<example>
|
|
71
|
+
<code>
|
|
72
|
+
try
|
|
73
|
+
{
|
|
74
|
+
await ProcessOrderAsync(order);
|
|
75
|
+
}
|
|
76
|
+
catch (ValidationException ex)
|
|
77
|
+
{
|
|
78
|
+
_logger.LogWarning(ex, "Validation failed for order {OrderId}", order.Id);
|
|
79
|
+
return BadRequest(ex.Errors);
|
|
80
|
+
}
|
|
81
|
+
catch (NotFoundException ex)
|
|
82
|
+
{
|
|
83
|
+
return NotFound(ex.Message);
|
|
84
|
+
}
|
|
85
|
+
catch (Exception ex) when (ex is TimeoutException or HttpRequestException)
|
|
86
|
+
{
|
|
87
|
+
_logger.LogWarning(ex, "Transient error, will retry");
|
|
88
|
+
throw; // Preserve stack trace!
|
|
89
|
+
}
|
|
90
|
+
catch (Exception ex)
|
|
91
|
+
{
|
|
92
|
+
_logger.LogError(ex, "Unexpected error processing order {OrderId}", order.Id);
|
|
93
|
+
throw; // Never "throw ex;"
|
|
94
|
+
}
|
|
95
|
+
</code>
|
|
96
|
+
</example>
|
|
97
|
+
</catching>
|
|
98
|
+
<custom_exceptions>
|
|
99
|
+
<template>
|
|
100
|
+
<code>
|
|
101
|
+
public class OrderProcessingException : Exception
|
|
102
|
+
{
|
|
103
|
+
public string OrderId { get; }
|
|
104
|
+
public string ErrorCode { get; }
|
|
105
|
+
|
|
106
|
+
public OrderProcessingException(string orderId, string message, string errorCode)
|
|
107
|
+
: base(message)
|
|
108
|
+
{
|
|
109
|
+
OrderId = orderId;
|
|
110
|
+
ErrorCode = errorCode;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public OrderProcessingException(string orderId, string message, Exception inner)
|
|
114
|
+
: base(message, inner)
|
|
115
|
+
{
|
|
116
|
+
OrderId = orderId;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
</code>
|
|
120
|
+
</template>
|
|
121
|
+
</custom_exceptions>
|
|
122
|
+
</exception_best_practices>
|
|
123
|
+
<result_pattern>
|
|
124
|
+
<libraries>
|
|
125
|
+
<library name="FluentResults">Rich API, multiple errors, chaining</library>
|
|
126
|
+
<library name="ErrorOr">Clean fluent API, functional style</library>
|
|
127
|
+
<library name="OneOf">Discriminated unions, exhaustive matching</library>
|
|
128
|
+
</libraries>
|
|
129
|
+
<erroror_example>
|
|
130
|
+
<code>
|
|
131
|
+
public async Task<ErrorOr<Order>> CreateOrderAsync(CreateOrderCommand cmd)
|
|
132
|
+
{
|
|
133
|
+
if (cmd.Items.Count == 0)
|
|
134
|
+
return Error.Validation("Order must have items");
|
|
135
|
+
|
|
136
|
+
var customer = await _customerRepo.FindAsync(cmd.CustomerId);
|
|
137
|
+
if (customer == null)
|
|
138
|
+
return Error.NotFound("Customer not found");
|
|
139
|
+
|
|
140
|
+
if (!customer.IsActive)
|
|
141
|
+
return Error.Validation("Customer account is inactive");
|
|
142
|
+
|
|
143
|
+
var order = new Order(cmd);
|
|
144
|
+
await _orderRepo.AddAsync(order);
|
|
145
|
+
|
|
146
|
+
return order;
|
|
147
|
+
}
|
|
148
|
+
// Controller usage
|
|
149
|
+
[HttpPost]
|
|
150
|
+
public async Task<IActionResult> CreateOrder(CreateOrderDto dto)
|
|
151
|
+
{
|
|
152
|
+
var result = await _orderService.CreateOrderAsync(dto.ToCommand());
|
|
153
|
+
|
|
154
|
+
return result.Match(
|
|
155
|
+
order => Ok(new OrderDto(order)),
|
|
156
|
+
errors => Problem(errors.First().Description)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
</code>
|
|
160
|
+
</erroror_example>
|
|
161
|
+
<chaining>
|
|
162
|
+
<code>
|
|
163
|
+
public async Task<ErrorOr<OrderResult>> ProcessOrderAsync(int orderId)
|
|
164
|
+
{
|
|
165
|
+
return await ValidateOrderAsync(orderId)
|
|
166
|
+
.Then(order => CalculatePriceAsync(order))
|
|
167
|
+
.Then(order => ProcessPaymentAsync(order))
|
|
168
|
+
.Then(order => SendConfirmationAsync(order));
|
|
169
|
+
}
|
|
170
|
+
</code>
|
|
171
|
+
</chaining>
|
|
172
|
+
</result_pattern>
|
|
173
|
+
<validation>
|
|
174
|
+
<fluentvalidation recommended="true">
|
|
175
|
+
<description>Powerful, fluent validation with separation of concerns</description>
|
|
176
|
+
<example>
|
|
177
|
+
<code>
|
|
178
|
+
public class CreateUserValidator : AbstractValidator<CreateUserDto>
|
|
179
|
+
{
|
|
180
|
+
public CreateUserValidator(IUserRepository repository)
|
|
181
|
+
{
|
|
182
|
+
RuleFor(x => x.Email)
|
|
183
|
+
.NotEmpty().WithMessage("Email is required")
|
|
184
|
+
.EmailAddress().WithMessage("Invalid email format")
|
|
185
|
+
.MustAsync(async (email, ct) =>
|
|
186
|
+
!await repository.ExistsAsync(email))
|
|
187
|
+
.WithMessage("Email already registered");
|
|
188
|
+
|
|
189
|
+
RuleFor(x => x.Password)
|
|
190
|
+
.NotEmpty()
|
|
191
|
+
.MinimumLength(8)
|
|
192
|
+
.Matches("[A-Z]").WithMessage("Must contain uppercase")
|
|
193
|
+
.Matches("[a-z]").WithMessage("Must contain lowercase")
|
|
194
|
+
.Matches("[0-9]").WithMessage("Must contain number");
|
|
195
|
+
|
|
196
|
+
RuleFor(x => x.Age)
|
|
197
|
+
.InclusiveBetween(18, 120);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
</code>
|
|
201
|
+
</example>
|
|
202
|
+
</fluentvalidation>
|
|
203
|
+
<data_annotations>
|
|
204
|
+
<description>Simple validation with attributes</description>
|
|
205
|
+
<use_for>DTOs, simple input validation</use_for>
|
|
206
|
+
<example>
|
|
207
|
+
<code>
|
|
208
|
+
public class CreateUserDto
|
|
209
|
+
{
|
|
210
|
+
[Required]
|
|
211
|
+
[EmailAddress]
|
|
212
|
+
public string Email { get; init; }
|
|
213
|
+
|
|
214
|
+
[Required]
|
|
215
|
+
[MinLength(8)]
|
|
216
|
+
public string Password { get; init; }
|
|
217
|
+
|
|
218
|
+
[Range(18, 120)]
|
|
219
|
+
public int Age { get; init; }
|
|
220
|
+
}
|
|
221
|
+
</code>
|
|
222
|
+
</example>
|
|
223
|
+
</data_annotations>
|
|
224
|
+
<validation_layers>
|
|
225
|
+
<layer name="Controller">Input format validation (DataAnnotations)</layer>
|
|
226
|
+
<layer name="Service">Business rules (FluentValidation)</layer>
|
|
227
|
+
<layer name="Domain">Invariants (guard clauses, exceptions)</layer>
|
|
228
|
+
</validation_layers>
|
|
229
|
+
</validation>
|
|
230
|
+
<aspnetcore_error_handling>
|
|
231
|
+
<iexceptionhandler recommended="true">
|
|
232
|
+
<description>Global exception handling (.NET 8+)</description>
|
|
233
|
+
<example>
|
|
234
|
+
<code>
|
|
235
|
+
public class GlobalExceptionHandler : IExceptionHandler
|
|
236
|
+
{
|
|
237
|
+
private readonly ILogger<GlobalExceptionHandler> _logger;
|
|
238
|
+
|
|
239
|
+
public GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger)
|
|
240
|
+
{
|
|
241
|
+
_logger = logger;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public async ValueTask<bool> TryHandleAsync(
|
|
245
|
+
HttpContext httpContext,
|
|
246
|
+
Exception exception,
|
|
247
|
+
CancellationToken ct)
|
|
248
|
+
{
|
|
249
|
+
_logger.LogError(exception, "Unhandled exception: {Message}", exception.Message);
|
|
250
|
+
|
|
251
|
+
var problemDetails = exception switch
|
|
252
|
+
{
|
|
253
|
+
ValidationException ex => new ProblemDetails
|
|
254
|
+
{
|
|
255
|
+
Type = "https://example.com/validation-error",
|
|
256
|
+
Title = "Validation Error",
|
|
257
|
+
Status = 400,
|
|
258
|
+
Detail = ex.Message
|
|
259
|
+
},
|
|
260
|
+
NotFoundException => new ProblemDetails
|
|
261
|
+
{
|
|
262
|
+
Type = "https://example.com/not-found",
|
|
263
|
+
Title = "Not Found",
|
|
264
|
+
Status = 404
|
|
265
|
+
},
|
|
266
|
+
_ => new ProblemDetails
|
|
267
|
+
{
|
|
268
|
+
Type = "https://example.com/internal-error",
|
|
269
|
+
Title = "Internal Server Error",
|
|
270
|
+
Status = 500,
|
|
271
|
+
Detail = "An unexpected error occurred"
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
problemDetails.Extensions["traceId"] = httpContext.TraceIdentifier;
|
|
276
|
+
|
|
277
|
+
httpContext.Response.StatusCode = problemDetails.Status ?? 500;
|
|
278
|
+
await httpContext.Response.WriteAsJsonAsync(problemDetails, ct);
|
|
279
|
+
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// Registration
|
|
284
|
+
builder.Services.AddProblemDetails();
|
|
285
|
+
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
|
|
286
|
+
app.UseExceptionHandler();
|
|
287
|
+
</code>
|
|
288
|
+
</example>
|
|
289
|
+
</iexceptionhandler>
|
|
290
|
+
<problem_details>
|
|
291
|
+
<description>RFC 7807 standard error format</description>
|
|
292
|
+
<format>
|
|
293
|
+
<code>
|
|
294
|
+
{
|
|
295
|
+
"type": "https://example.com/validation-error",
|
|
296
|
+
"title": "Validation Error",
|
|
297
|
+
"status": 400,
|
|
298
|
+
"detail": "Email is required",
|
|
299
|
+
"instance": "/api/users",
|
|
300
|
+
"traceId": "00-abc123..."
|
|
301
|
+
}
|
|
302
|
+
</code>
|
|
303
|
+
</format>
|
|
304
|
+
</problem_details>
|
|
305
|
+
</aspnetcore_error_handling>
|
|
306
|
+
<logging_errors>
|
|
307
|
+
<rules>
|
|
308
|
+
<rule>Always include exception object: LogError(ex, "message")</rule>
|
|
309
|
+
<rule>Add context: orderId, userId, operation name</rule>
|
|
310
|
+
<rule>Use structured logging with templates</rule>
|
|
311
|
+
<rule>Include correlation ID for tracing</rule>
|
|
312
|
+
</rules>
|
|
313
|
+
<example>
|
|
314
|
+
<code>
|
|
315
|
+
try
|
|
316
|
+
{
|
|
317
|
+
await ProcessOrderAsync(order);
|
|
318
|
+
}
|
|
319
|
+
catch (Exception ex)
|
|
320
|
+
{
|
|
321
|
+
_logger.LogError(ex,
|
|
322
|
+
"Failed to process order {OrderId} for customer {CustomerId}. Amount: {Amount}",
|
|
323
|
+
order.Id, order.CustomerId, order.TotalAmount);
|
|
324
|
+
throw;
|
|
325
|
+
}
|
|
326
|
+
</code>
|
|
327
|
+
</example>
|
|
328
|
+
<never_log>
|
|
329
|
+
<item>Passwords (even hashed)</item>
|
|
330
|
+
<item>Credit card numbers</item>
|
|
331
|
+
<item>API keys and tokens</item>
|
|
332
|
+
<item>Personal identification numbers</item>
|
|
333
|
+
</never_log>
|
|
334
|
+
</logging_errors>
|
|
335
|
+
<anti_patterns>
|
|
336
|
+
<avoid name="empty_catch">
|
|
337
|
+
<bad>catch (Exception) { }</bad>
|
|
338
|
+
<why>Swallows errors silently</why>
|
|
339
|
+
</avoid>
|
|
340
|
+
<avoid name="catch_and_throw_new">
|
|
341
|
+
<bad>catch (Exception ex) { throw new Exception("Error", ex); }</bad>
|
|
342
|
+
<why>Loses original exception type</why>
|
|
343
|
+
</avoid>
|
|
344
|
+
<avoid name="throw_ex">
|
|
345
|
+
<bad>throw ex;</bad>
|
|
346
|
+
<why>Resets stack trace</why>
|
|
347
|
+
<good>throw;</good>
|
|
348
|
+
</avoid>
|
|
349
|
+
<avoid name="exception_for_flow_control">
|
|
350
|
+
<bad>Using exceptions for expected business logic</bad>
|
|
351
|
+
<why>Expensive, unclear intent</why>
|
|
352
|
+
<good>Use Result pattern for expected failures</good>
|
|
353
|
+
</avoid>
|
|
354
|
+
</anti_patterns>
|