Hi, need help with one interesting thing:
i have ES6 class which i import to meteor code, inside this class i used throw new Meteor.Error() to throw an error up to stack BUT nothing happens on client and on the server console. ES6 CLASS:
export var SMSController = class _SMSController {
constructor(companyId) {
throw new Meteor.Error(500);
}
}
METEOR METHOD:
import {SMSController} from '/class/SMSController';
Meteor.methods({
createInvitationDetails: function (invitationDetails, options = {}) {
if (options.sms_notice_dates) {
let sms = new SMSController(Meteor.getCurrentCompanyId(Meteor.userId()));
}
}
})
Something else must be impacting your constructor call then. I’ve created a quick repro based on your code approach/structure, and it’s working properly. I’ve removed your options.sms_notice_dates check just to make sure, and everything works as it should. Quick test steps:
meteor create meteor-forum-26966-meteor-error
Create a /class directory.
Within /class, create sms_controller.js:
export class SMSController {
constructor(companyId) {
console.log(`Constructor called with ${companyId}`);
throw new Meteor.Error(500);
}
}
Within /class, create methods.js:
import { SMSController } from '/class/sms_controller';
Meteor.methods({
createInvitationDetails(invitationDetails, options = {}) {
const sms = new SMSController(123);
}
});
Start your app, then call the following from your browser console:
Small side note - you might want to look over Meteor 1.3+'s new application structure options. I noticed you’re currently using imports/exports but not leveraging Meteor’s newer /import directory approach.