-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Is your feature request related to a problem? Please describe.
When ApiException<T> is thrown is does not contain the response body
Having the response body is very useful when catching errors (especially when the destination server added more details about the error in the response body)
Describe the solution you'd like
I suggest to add response.getBodyAsAny() every time we are creating ApiException
For instance, instead:
throw new ApiException<undefined>(response.httpStatusCode, "Bad Request.", undefined, response.headers);
we will generate:
throw new ApiException(response.httpStatusCode, "Bad Request.", await response.getBodyAsAny(), response.headers);
Describe alternatives you've considered
For now, in order to address the problem we are running a this post generator script:
import * as replace from 'replace-in-file'
replace.sync({
files: 'src/generated/apis/**',
from: /new ApiException<undefined>/g,
to: 'new ApiException',
countMatches: true,
});
replace.sync({
files: 'src/generated/apis/**',
from: /undefined, response.headers/g,
to: 'await response.getBodyAsAny(), response.headers',
countMatches: true,
});
Even though it does the trick, this is obviously a hack and it will be better if this will be part of the original generated code
Reactions are currently unavailable