Closed StefanKoenigMUC closed 4 years ago
the Observables are handled by Angular HttpClient. So, this should work:
service.method(params).pipe(first()).subscribe(
result => console.log(`Success! ${JSON.stringify(result)}`),
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
// Client-side error
console.error('Client-side request error');
console.error(err.error);
} else {
// Server-generated error
let error = err.error;
if (typeof error === 'string') {
try {
error = JSON.parse(error);
} catch (e) {
error = null;
}
}
console.log(`Error ${err.status}: ${JSON.stringify(error)}`);
});
)
thanks a lot, that helped me! :-)
Hi there,
still very pleased by ng-openapi-gen (.. regarding the other bug in windows I opened weeks ago, still only agenda, but project work is overwhelming right now..).
But for now there is another problem I run into:
I've specification like this:
for success case everything is fine, but the non-success case -> 404, I'm not sure how to handle this.
Accessing the service looks like this.
if an error is thrown, I'm redirected to the error =>, but the error itself is undefined.
Is there a way to access the ProblemDetails entity? (or is there any other way available for handling return codes != 200?)
Thanks in advance!, Stefan