mirror of https://github.com/vector-im/riot-web
better error handling when creating rest user fails
parent
b88dc0ffd5
commit
4c79e3bd0d
|
@ -14,12 +14,23 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const util = require('util');
|
const {exec} = require('child_process');
|
||||||
const exec = util.promisify(require('child_process').exec);
|
|
||||||
const request = require('request-promise-native');
|
const request = require('request-promise-native');
|
||||||
const RestSession = require('./session');
|
const RestSession = require('./session');
|
||||||
const RestMultiSession = require('./multi');
|
const RestMultiSession = require('./multi');
|
||||||
|
|
||||||
|
function execAsync(command, options) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(command, options, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
resolve({stdout, stderr});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = class RestSessionCreator {
|
module.exports = class RestSessionCreator {
|
||||||
constructor(synapseSubdir, hsUrl, cwd) {
|
constructor(synapseSubdir, hsUrl, cwd) {
|
||||||
this.synapseSubdir = synapseSubdir;
|
this.synapseSubdir = synapseSubdir;
|
||||||
|
@ -56,14 +67,7 @@ module.exports = class RestSessionCreator {
|
||||||
registerCmd
|
registerCmd
|
||||||
].join(';');
|
].join(';');
|
||||||
|
|
||||||
try {
|
await execAsync(allCmds, {cwd: this.cwd, encoding: 'utf-8'});
|
||||||
await exec(allCmds, {cwd: this.cwd, encoding: 'utf-8'});
|
|
||||||
} catch (result) {
|
|
||||||
// const lines = result.stdout.trim().split('\n');
|
|
||||||
// const failureReason = lines[lines.length - 1];
|
|
||||||
// const logs = (await exec("tail -n 100 synapse/installations/consent/homeserver.log")).stdout;
|
|
||||||
throw new Error(`creating user ${username} failed, script output:\n ${result.stdout.trim()}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _authenticate(username, password) {
|
async _authenticate(username, password) {
|
||||||
|
|
Loading…
Reference in New Issue