mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Added proper error response (#1814)
This commit is contained in:
parent
1189362466
commit
eff0c5e8d0
@ -438,7 +438,14 @@ class ApiClient {
|
|||||||
{{#usePromises}}return new Promise((resolve, reject) => {
|
{{#usePromises}}return new Promise((resolve, reject) => {
|
||||||
request.end((error, response) => {
|
request.end((error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error);
|
var err = {};
|
||||||
|
err.status = response.status;
|
||||||
|
err.statusText = response.statusText;
|
||||||
|
err.body = response.body;
|
||||||
|
err.response = response;
|
||||||
|
err.error = error;
|
||||||
|
|
||||||
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
var data = this.deserialize(response, returnType);
|
var data = this.deserialize(response, returnType);
|
||||||
|
@ -89,6 +89,11 @@ class ApiClient {
|
|||||||
*/
|
*/
|
||||||
this.requestAgent = null;
|
this.requestAgent = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allow user to add superagent plugins
|
||||||
|
*/
|
||||||
|
this.plugins = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -347,6 +352,14 @@ class ApiClient {
|
|||||||
var url = this.buildUrl(path, pathParams);
|
var url = this.buildUrl(path, pathParams);
|
||||||
var request = superagent(httpMethod, url);
|
var request = superagent(httpMethod, url);
|
||||||
|
|
||||||
|
if (this.plugins !== null) {
|
||||||
|
for (var index in this.plugins) {
|
||||||
|
if (this.plugins.hasOwnProperty(index)) {
|
||||||
|
request.use(this.plugins[index])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// apply authentications
|
// apply authentications
|
||||||
this.applyAuthToRequest(request, authNames);
|
this.applyAuthToRequest(request, authNames);
|
||||||
|
|
||||||
@ -420,7 +433,14 @@ class ApiClient {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
request.end((error, response) => {
|
request.end((error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error);
|
var err = {};
|
||||||
|
err.status = response.status;
|
||||||
|
err.statusText = response.statusText;
|
||||||
|
err.body = response.body;
|
||||||
|
err.response = response;
|
||||||
|
err.error = error;
|
||||||
|
|
||||||
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
var data = this.deserialize(response, returnType);
|
var data = this.deserialize(response, returnType);
|
||||||
|
Loading…
Reference in New Issue
Block a user