One of my challenges involves working with the ProjectDecommissionRequestController controller and a TypeScript client app. The TypeScript client app is designed to print specific strings based on status codes, such as displaying a generic error message for a 500 status code.
const response = await fetch(`api/projectdecommissionrequest`, {
body: JSON.stringify(postBody),
headers: new Headers({
"Accept": "application/json",
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
}),
method: "POST",
});
console.log(response.status);
In the controller, there is a call to another class that performs a check and throws an error:
if (!repoUrlFormatMatch.Success)
throw new FormatException($"The repositoryUri '{repositoryUri}' did not conform to the expected format for an Azure Devops Git repository.");
I am looking to adjust the status code for this exception to something other than 500 in order to provide a more specific error message.
Any suggestions or assistance would be greatly appreciated. Thank you!