I’ve been battling with this for a while, so apologies if its user error but I cannot find the issue.
I’m developing a server rendered blazor web app and am making a JsonApiClient request to a service whose response is marked with IHasErrorStatus and has a ResponseStatus, but the responsestatus is populated with the Exception type name, rather than the exception’s message. What could I be doing wrong?
public class PatchTableMappingResponse : IHasErrorStatus
{
public int TargetTableId { get; set; }
public string TargetTable { get; set; } = null!;
public bool Ignore { get; set; }
public bool AutoResolve { get; set; }
public bool Extend { get; set; }
public ResponseStatus? Error { get; }
}
public async Task<PatchTableMappingResponse> PatchAsync(PatchTableMapping request)
{
CheckDataSyncIsPaused();
var existingTableMapping = Db.Single<dsMapping.TargetTable>(tt => tt.TargetTableId == request.TargetTableId);
if (existingTableMapping == null)
{
throw new NotFoundException("Table mapping not found.");
}
if (PatchTableMappingValues(existingTableMapping, request))
{
try
{
await Db.SaveAsync(existingTableMapping);
}
catch (SqlException ex) when (
ex.Number == 2601 || //Cannot insert duplicate key row in object '<Object Name>' with unique index '<Index Name>'.
ex.Number == 2627) // Violation of PRIMARY KEY constraint '%.*ls'. Cannot insert duplicate key in object '%.*ls'.
{
throw new NameNotUniqueException("Target table name must be unique.");
}
}
return new PatchTableMappingResponse
{
TargetTableId = existingTableMapping.TargetTableId,
TargetTable = existingTableMapping.TargetTableName ?? string.Empty,
Ignore = !existingTableMapping.ShouldProcess,
AutoResolve = existingTableMapping.ShouldAutoResolve,
Extend = existingTableMapping.ShouldExtend
};
}