How to use the abap-adt-api.adtException function in abap-adt-api

To help you get started, we’ve selected a few abap-adt-api 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 marcellourbani / vscode_abap_remote_fs / client / src / adt / AdtServer.ts View on Github external
public async saveFile(
    file: AbapNode,
    content: Uint8Array,
    uri: Uri
  ): Promise {
    if (file.isFolder) throw FileSystemError.FileIsADirectory()
    if (!isAbapNode(file))
      throw FileSystemError.NoPermissions("Can only save source code")

    const obj = file.abapObject
    if (!obj.structure) await file.stat(this.client)
    const lm = LockManager.get()

    // check file is locked. Waits if locking is in progress
    if (!(await lm.getFinalStatus(uri)))
      throw adtException(`Object not locked ${obj.type} ${obj.name}`)

    const transport = await this.selectTransportIfNeeded(
      obj,
      lm.getTransport(uri)
    )

    if (!transport.cancelled) {
      let lockId = lm.getLockId(uri)
      try {
        await this.runInSession(client =>
          obj.setContents(client, content, lockId, transport.transport)
        )
      } catch (e) {
        if (isExpired(e) || e.type === LOCKEXPIRED) {
          if (await reconnectExpired(uri)) {
            lockId = lm.getLockId(uri)
github marcellourbani / vscode_abap_remote_fs / client / src / adt / AdtServer.ts View on Github external
obj.setContents(client, content, lockId, transport.transport)
        )
      } catch (e) {
        if (isExpired(e) || e.type === LOCKEXPIRED) {
          if (await reconnectExpired(uri)) {
            lockId = lm.getLockId(uri)
            await this.runInSession(client =>
              obj.setContents(client, content, lockId, transport.transport)
            )
          } else throw e
        } else throw e
      }

      await file.stat(this.client)
      await lm.unlock(uri)
    } else throw adtException("Object can't be saved without a transport")
  }