apinf / meteor-api-umbrella

Meteor wrapper for the API Umbrella Admin API.
MIT License
5 stars 1 forks source link

Add error treatment to apiBackends calls #1

Closed mauriciovieira closed 6 years ago

mauriciovieira commented 9 years ago

Nowadays, apiUmbrellaWeb.adminApi.v1.apiBackends.createApiBackend(constructedBackend) does not treat errors. In case of failure https://github.com/brylie/meteor-api-umbrella/blob/master/server/admin-api/v1/apiBackends.js#L29 should treat the error and throw ApiUmbrellaError with the details.

For instance, Error.message now is a string like 'failed [422] {"errors":{"backend_protocol":["is not included in the list"]}}'. It should be a ApiUmbrellaError with

http_status: 422,
errors: {"backend_protocol":["is not included in the list"]}

along with the default message.

Related documentation:

mauriciovieira commented 8 years ago

@brylie I am looking into this now.

brylie commented 8 years ago

@mauriciovieira thanks. I can help repeat the basic pattern in the other API endpoints, once you have a working example for createApiBackend.

mauriciovieira commented 8 years ago

@brylie what I currently get using the same credentials of api-umbrella @ apinf.io and running meteor --settings settings.json test-packages ./ is screen shot 2015-11-09 at 8 49 43 am

so I am now trying to set my local api-umbrella server to better debug the rails/node.js part.

brylie commented 8 years ago

Be sure to include a trailing slash in your base_url configuration.

brylie commented 8 years ago

Also, the backend changes may need to be published. We can do this via the Admin API Config Publish endpoint. Alternatively, this can be done via the API Umbrella admin UI.

mauriciovieira commented 8 years ago

@brylie The trailling slash is there. At this point I think I don't need to publish the changes, I just want to get the errors.

mauriciovieira commented 8 years ago

For some reason, now I am getting the 422 error. This one is an umbrella's bug, but can be used to work with: screen shot 2015-11-11 at 8 08 23 am

brylie commented 8 years ago

Try working in my development branch.

mauriciovieira commented 8 years ago

@brylie I made some improvements with error handling on mauriciovieira/meteor-api-umbrella:spike branch

See https://github.com/mauriciovieira/meteor-api-umbrella/blob/20d01fbd3283d5eb1e7cbbee5732aa481dd5ed4d/server/apiUmbrellaError.js

It is still not fully functional, but I believe I am in the correct path.

brylie commented 8 years ago

@mauriciovieira I have merged your pull request.

Nazarah commented 6 years ago

closing since the work related to this task has been merged as a PR