How to use the @seagull/libraries.tryGet function in @seagull/libraries

To help you get started, we’ve selected a few @seagull/libraries examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seagull-js / seagull / packages / services-soap / src / mode / seed.ts View on Github external
private handleError(seed: FxSt, error: NodeSoapFaultError | any) {
    const fault: NodeSoapFault11 | NodeSoapFault12 = tryGet(
      error as NodeSoapFaultError,
      e => e.cause.root.Envelope.Body.Fault
    )
    if (fault) {
      const xmlFault: IXmlFault = this.convertFault(fault)
      const xmlResponse = (error as NodeSoapFaultError).body
      seed.set({ xmlFault, xmlResponse })
      throw new SoapFaultError(
        `Fault ${xmlFault.code}: ${xmlFault.description}`,
        xmlFault
      )
    }
    throw new SoapError('Unknown error', error)
  }