Skip to content

Commit

Permalink
[ADD] CDPErrorTag in http response header
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander van Delft committed Jun 27, 2024
1 parent 321a68b commit 221dfa2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions CometServer/Modules/10-25/ApiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,5 +1047,24 @@ protected CometTask CreateAndRegisterCometTask(Guid actor, string topContainerNa

return cometTask;
}

/// <summary>
/// Adds a specific CDP error tag to an <see cref="HttpResponse"/> message
/// </summary>
/// <param name="httpResponse">The <see cref="HttpResponse"/></param>
/// <param name="errorTag">The the Error tag</param>
protected void AddErrorTagHeader(HttpResponse httpResponse, string errorTag)
{
var errorTagHeader = "CDPErrorTag";

if (!httpResponse.Headers.ContainsKey(errorTagHeader))
{
httpResponse.Headers[errorTagHeader] = errorTag;
}
else
{
httpResponse.Headers.TryAdd(errorTagHeader, errorTag);
}
}
}
}
4 changes: 3 additions & 1 deletion CometServer/Modules/10-25/EngineeringModelApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,9 @@ protected async Task PostResponseData(PostRequestData postRequestData, string re

if (!IsPostAllowedOnIterationSetup(resourceProcessor, iteration))
{
throw new Cdp4ModelValidationException($"It is not allowed to write data to a Frozen {nameof(IterationSetup)}, or its full containment tree. (#FROZEN_ITERATION).");
this.AddErrorTagHeader(httpResponse, "#FROZEN_ITERATION");

throw new Cdp4ModelValidationException($"It is not allowed to write data to a Frozen {nameof(IterationSetup)}, or its full containment tree.");
}

credentialsService.Credentials.Iteration = iteration;
Expand Down

0 comments on commit 221dfa2

Please sign in to comment.