How to use the abap-adt-api.isAdtError 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 / operations / AdtObjectActivator.ts View on Github external
public async activate(object: AbapObject, uri: Uri) {
    // TODO: handle multiple inactive components
    const inactive = object.getActivationSubject()
    let result
    let message
    try {
      result = await this.client.activate(inactive.name, inactive.path)
      if (result.inactive.length > 0) {
        const inactives = inactiveObjectsInResults(result)
        result = await this.client.activate(inactives)
      }
    } catch (e) {
      if (isAdtError(e) && e.type === "invalidMainProgram") {
        const provider = IncludeLensP.get()
        const mainProg = await provider.selectIncludeIfNeeded(uri)
        if (mainProg)
          result = await this.client.activate(
            inactive.name,
            inactive.path,
            mainProg
          )
      } else message = e.toString()
    }
    if (result && result.success) {
      await inactive.loadMetadata(this.client)
    } else {
      message =
        (result && result.messages[0] && result.messages[0].shortText) ||
        message ||