export function parsePayload()

in typescript/src/pubsub/apple-common.ts [520:544]


export function parsePayload(
  body: Option<string>,
): Error | StatusUpdateNotification {
  try {
    const notification: unknown = JSON.parse(body ?? '');
    console.log(`[3fd06200] ${body}`);
    const parsedNotification = parseNotification(notification);
    console.log(`[9fa7f297] ${body}`);
    if (parsedNotification.kind === ResultKind.Ok) {
      console.log(`(ec0a5f83) ${body}`);
      return parsedNotification.value;
    }
    console.log(
      `debugLogPayload (parse error: ${
        parsedNotification.err
      }): ${debugLogPayload(notification)}`,
    );
    throw Error(
      `The payload could not be parsed due to ${parsedNotification.err}`,
    );
  } catch (e) {
    console.log('Error during the parsing of the HTTP Payload body: ' + e);
    return e as Error;
  }
}