After much research, I managed to get this job, and I think that it answers your question.
Remember that I am using Meteor 1.6, but it should give you information to make it work on your side.
In publication / publication:
try { // get the data and add it to the publication ... self.ready(); } catch (exception) { logger.error(exception); // send the exception to the client through the publication this.error(new Meteor.Error('500', 'Error getting data from API', exception)); }
In the user interface component:
const errorFromApi = new ReactiveVar(); export default withTracker(({ match }) => { const companyId = match.params._id; let subscription; if (!errorFromApi.get()) { subscription = Meteor.subscribe('company.view', companyId, { onStop: function (e) { errorFromApi.set(e); } }); } else { subscription = { ready: () => { return false; } }; } return { loading: !subscription.ready(), company: Companies.findOne(companyId), error: errorFromApi.get() }; })(CompanyView);
From here you only need to get the support of the error and display the component as desired.
This is the error prop structure (obtained by the onStop from subscribe ):
{ error: String, reason: String, details: String }
[change]
The reason the Meteor.subscribe() condition Meteor.subscribe() is to avoid the annoying endless loop that you will get from the natural updates withTracker() , which will cause new publications / new errors from the publication, etc.
source share