From 4c64f1c134ac64228e0162a2cc0e84f0187533c9 Mon Sep 17 00:00:00 2001 From: MattMo Date: Fri, 28 Jul 2023 15:23:29 -0700 Subject: [PATCH] Modified Javascript Client generator to throw the response instead of a message so that behavior of the code using the Client can changed based on the response returned. Bumped package version to 1.7.2 --- Rest.Net/Rest.Net.csproj | 2 +- Rest.Net/RestJavascriptClientGenerator.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index f47856b..7a50d05 100644 --- a/Rest.Net/Rest.Net.csproj +++ b/Rest.Net/Rest.Net.csproj @@ -17,7 +17,7 @@ MontoyaTech.Rest.Net MontoyaTech.Rest.Net True - 1.7.1 + 1.7.2 Logo_Symbol_Black_Outline.png diff --git a/Rest.Net/RestJavascriptClientGenerator.cs b/Rest.Net/RestJavascriptClientGenerator.cs index 7b3be37..a072e56 100644 --- a/Rest.Net/RestJavascriptClientGenerator.cs +++ b/Rest.Net/RestJavascriptClientGenerator.cs @@ -502,6 +502,8 @@ namespace MontoyaTech.Rest.Net if (routeResponse != null) writer.WriteLine($"@returns {{{this.GetTypeFullyResolvedName(routeResponse.ResponseType)}}}"); + writer.WriteLine("@throws {Response} If response status was not ok."); + writer.Outdent().WriteLine("*/"); //Generate the route function header @@ -666,13 +668,13 @@ namespace MontoyaTech.Rest.Net } writer.Outdent().WriteLine("} else {").Indent(); - writer.WriteLine("throw `Unexpected http response status: ${response.status}`;"); + writer.WriteLine("throw response;"); writer.Outdent().WriteLine("}"); } else { writer.WriteBreak().WriteLine("if (!response.ok) {").Indent(); - writer.WriteLine("throw `Unexpected http response status: ${response.status}`;"); + writer.WriteLine("throw response;"); writer.Outdent().WriteLine("}"); }