'use strict';


const { EngineStartupError } = require('../error');
const { setLogger, attachRequire } = require('../utilities');
const { processOptions } = require('../options');
const { httpStartServer } = require('./http');


/**
 * Start server for each protocol, for the moment only HTTP
 *
 * @param {object} options
 * @param {object} options.idl - IDL definitions
 */
const startServer = async function (options) {
  try {
    attachRequire();

    const opts = await processOptions(options);

    if (opts.logger) {
      setLogger({ logger: opts.logger });
    }

    const server = await Promise.all([
      httpStartServer(opts),
    ]);
    return server;
  // Make sure all exceptions thrown at startup follow the EngineStartupError signature
  } catch (innererror) {
    if (innererror instanceof EngineStartupError) {
      throw innererror;
    } else {
      throw new EngineStartupError(innererror.message, { reason: 'UNKNOWN', innererror });
    }
  }
};


module.exports = {
  startServer,
};

@@ -716,16 +716,21 @@
 p follow
+%0A  //
  the Eng
@@ -925,16 +925,24 @@
 ssage, %7B
+%0A       
  reason:
@@ -952,16 +952,24 @@
 NKNOWN',
+%0A       
  innerer
@@ -971,16 +971,23 @@
 nererror
+,%0A     
  %7D);%0A   

Fix line width