Skip to content

Commit

Permalink
Merge pull request #54 from wemogy/fix/error-msg
Browse files Browse the repository at this point in the history
Improved exception message for filtered entity
  • Loading branch information
SebastianKuesters authored Dec 2, 2022
2 parents a553e81 + b050cfe commit 9e1eef3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ public static NotFoundErrorException EntityNotFound(string id)
$"Entity with id {id} not found");
}

public static NotFoundErrorException EntityNotFound(string id, string partitionKey)
public static NotFoundErrorException EntityNotFound(string id, string partitionKey, string hint = "")
{
if (hint != string.Empty)
{
hint = $" ({hint})";
}

return Error.NotFound(
"EntityNotFound",
$"Entity with id {id} was not found in partition {partitionKey}");
$"Entity with id {id} was not found in partition {partitionKey}{hint}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public async Task<TEntity> GetAsync(
{
throw DatabaseError.EntityNotFound(
id,
partitionKey);
partitionKey,
"Entity is soft deleted");
}

var filter = await GetReadFilter();
Expand All @@ -36,7 +37,8 @@ public async Task<TEntity> GetAsync(
{
throw DatabaseError.EntityNotFound(
id,
partitionKey);
partitionKey,
"Entity does not match read filter");
}

await PropertyFilters.ApplyAsync(entity);
Expand Down

0 comments on commit 9e1eef3

Please sign in to comment.