Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better defaults for ExceptionDescription? #4901

Open
sheam opened this issue May 23, 2024 · 0 comments
Open

Better defaults for ExceptionDescription? #4901

sheam opened this issue May 23, 2024 · 0 comments

Comments

@sheam
Copy link

sheam commented May 23, 2024

By default the process function the typescript client uses A server side error occurred for all expected errors. In the case of 400, and 403 this doesn't really make sense. So I would like to change the message used to more closely resemble the error code.

From looking at the Client.ProcessResponse.HandleStatusCode template, it looks like it uses an response.ExceptionDescription property. This is nice for making changes to individual endpoints. But it would be nice if there was a way to say if it is a 403 default the description to "Forbidden" or something more related to the httpCode. Otherwise, I am copy and pasting the same strings everywhere.

Is there a way I can do this in my configuration? Or would I need to override the whole template:
https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.CodeGeneration.TypeScript/Templates/Client.ProcessResponse.HandleStatusCode.liquid

Thanks,
~Shea M

@sheam sheam changed the title How can I make use of ExceptionDescription in my typescript clients? Better defaults for ExceptionDescription? May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant