Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Wrap fallible ORM functions in Try/Catch #2709

@tevoinea

Description

@tevoinea

Some ORM operations are fallible. We have existing code that attempts to handle the failure modes using .IsError but it turns out that they can also throw exceptions. Here's an example:

public async Task<ResultVoid<(HttpStatusCode Status, string Reason)>> Replace(T entity) {
var tableClient = await GetTableClient(typeof(T).Name);
var tableEntity = _entityConverter.ToTableEntity(entity);
var response = await tableClient.UpsertEntityAsync(tableEntity, TableUpdateMode.Replace);
if (response.IsError) {
return ResultVoid<(HttpStatusCode, string)>.Error(((HttpStatusCode)response.Status, response.ReasonPhrase));
} else {
// update ETag on success
entity.ETag = response.Headers.ETag;
return ResultVoid<(HttpStatusCode, string)>.Ok();
}
}

That example can also throw Azure.RequestFailedException.

Feature request

For all fallible ORM functions, wrap them in try/catch and return the appropriate OneFuzzResult type.

AB#42650423

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions