message: Add more context to Alfred Connection errors
diff: -/* eslint-disable no-null/no-null */
  /*!
  * Copyright (c) Microsoft Corporation. All rights reserved.
  * Licensed under the MIT License.
  @@ -188,7 +187,10 @@ export function configureWebSocketServices(
  }
  if (!message.token) {
  // eslint-disable-next-line prefer-promise-reject-errors
  - return Promise.reject("Must provide an authorization token");
  + return Promise.reject({
  + code: 403,
  + message: "Must provide an authorization token",
  + });
  }
  // Validate token signature and claims
  @@ -200,14 +202,14 @@ export function configureWebSocketServices(
  isTokenExpiryEnabled);
  if (!claims) {
  // eslint-disable-next-line prefer-promise-reject-errors
  - return Promise.reject("Invalid claims");
  + return Promise.reject({ code: 401, message: "Invalid claims" });
  }
  try {
  await tenantManager.verifyToken(claims.tenantId, token);
  } catch (err) {
  // eslint-disable-next-line prefer-promise-reject-errors
  - return Promise.reject("Invalid token");
  + return Promise.reject({ code: 403, message: "Invalid token" });
  }
  const clientId = generateClientId();
  @@ -237,10 +239,12 @@ export function configureWebSocketServices(
  const version = selectProtocolVersion(connectVersions);
  if (!version) {
  // eslint-disable-next-line prefer-promise-reject-errors
  - return Promise.reject(
  - `Unsupported client protocol.` +
  + return Promise.reject({
  + code: 400,
  + message: `Unsupported client protocol. ` +
  `Server: ${protocolVersions}. ` +
  - `Client: ${JSON.stringify(connectVersions)}`);
  + `Client: ${JSON.stringify(connectVersions)}`,
  + });
  }
  const detailsP = storage.getOrCreateDocument(claims.tenantId, claims.documentId);
  @@ -251,8 +255,8 @@ export function configureWebSocketServices(
  if (clients.length > maxNumberOfClientsPerDocument) {
  // eslint-disable-next-line prefer-promise-reject-errors
  return Promise.reject({
  - code: 400,
  - message: "Too many clients are already connected to this document.",
  + code: 429,
  + message: "Too Many Clients Connected to Document",
  retryAfter: 5 * 60,
  });
  }
  @@ -269,7 +273,10 @@ export function configureWebSocketServices(
  setExpirationTimer(lifeTimeMSec);
  } else {
  // eslint-disable-next-line prefer-promise-reject-errors
  - return Promise.reject("Invalid token expiry");
  + return Promise.reject({
  + code: 401,
  + message: "Invalid token expiry",
  + });
  }
  }
  