How to use the @bentley/ui-abstract.UiError function in @bentley/ui-abstract

To help you get started, we’ve selected a few @bentley/ui-abstract 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 imodeljs / imodeljs / ui / framework / src / ui-framework / widgets / WidgetDef.tsx View on Github external
if (typeof this.classId === "string") {
        // istanbul ignore else
        if (this.classId)
          this._widgetControl = ConfigurableUiManager.createControl(this.classId, this.id, this.applicationData) as WidgetControl;
        usedClassId = this.classId;
      } else {
        const info = new ConfigurableCreateInfo(this.classId.name, this.id, this.id);
        usedClassId = this.classId.name;
        this._widgetControl = new this.classId(info, this.applicationData) as WidgetControl;
      }

      // istanbul ignore else
      if (this._widgetControl) {
        if (this._widgetControl.getType() !== type) {
          throw new UiError(UiFramework.loggerCategory(this), "getWidgetControl: '" + usedClassId + "' is NOT a " + type + "; it is a " + this._widgetControl.getType());
        }

        this._widgetControl.widgetDef = this;
        this._widgetControl.initialize();
      }
    }

    return this._widgetControl;
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / UiFramework.ts View on Github external
public static get backstageManager(): BackstageManager {
    // istanbul ignore next
    if (!UiFramework._backstageManager)
      throw new UiError(UiFramework.loggerCategory(this), UiFramework._complaint);
    return UiFramework._backstageManager;
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / zones / toolsettings / ToolInformation.ts View on Github external
public get toolUiProvider(): ToolUiProvider | undefined {
    if (!this._toolUiProvider) {
      let provider: ToolUiProvider | undefined;

      if (ConfigurableUiManager.isControlRegistered(this.toolId)) {
        provider = ConfigurableUiManager.createControl(this.toolId, this.toolId) as ToolUiProvider;
      } else {
        if (ToolUiManager.useDefaultToolSettingsProvider && this.toolId === ToolUiManager.toolIdForToolSettings)
          provider = ConfigurableUiManager.createControl("DefaultToolSettings", this.toolId) as ToolUiProvider;
      }
      // istanbul ignore else
      if (provider) {
        if (provider.getType() !== ConfigurableUiControlType.ToolUiProvider) {
          throw new UiError(UiFramework.loggerCategory(this), "toolUiProvider: toolId '" + this.toolId + "' is registered to a control that is NOT a ToolUiProvider");
        }

        provider.initialize();
        this._toolUiProvider = provider;
      }
    } else {
      // if the tool settings are coming from tool, reinitialize provider so latest properties published from tool are displayed in UI
      if (ToolUiManager.useDefaultToolSettingsProvider && this._toolUiProvider)
        this._toolUiProvider.initialize();
    }
    return this._toolUiProvider;
  }
}
github imodeljs / imodeljs / ui / framework / src / ui-framework / shared / MenuItem.tsx View on Github external
this._actionItem = new CommandItemDef(props.item);

      // Copy over icon, label & badgeType from the item
      if (!this.iconSpec)
        this.iconSpec = this._actionItem.iconSpec;
      if (!this.label)
        this.setLabel(this._actionItem.label);
      if (!this.badgeType)
        this.badgeType = this._actionItem.badgeType;
    } else if (props.submenu) {
      props.submenu.forEach((childProps: MenuItemProps) => {
        const childItem = new MenuItem(childProps, onSelection);
        this._submenu.push(childItem);
      });
    } else {
      throw new UiError(UiFramework.loggerCategory(this), `Either 'item' or 'submenu' must be specified for '${props.id}'.`);
    }
  }
github imodeljs / imodeljs / ui / components / src / ui-components / viewport / ViewportComponent.tsx View on Github external
private async getViewState(): Promise {
    let viewState: ViewState;

    if (this.props.viewState) {
      viewState = this.props.viewState;
    } else if (this.props.viewDefinitionId) {
      viewState = await this.props.imodel.views.load(this.props.viewDefinitionId);
      // istanbul ignore next
      if (!viewState) {
        throw new UiError(UiComponents.loggerCategory(this), `View state failed to load`);
      }
    } /* istanbul ignore next */ else {
      throw new UiError(UiComponents.loggerCategory(this), `Either viewDefinitionId or viewState must be provided as a ViewportComponent Prop`);
    }

    return viewState;
  }
github imodeljs / imodeljs / ui / components / src / ui-components / tree / controlled / component / TreeRenderer.tsx View on Github external
function useContextWithoutDefaultValue<p>(ConsumingComponent: React.ComponentType</p><p>) {
    const value = useContext(context);
    /* istanbul ignore if */
    if (value === undefined) {
      throw new UiError(
        UiComponents.loggerCategory(ConsumingComponent),
        `'${getClassName(ConsumingComponent)}' expects to be wrapped by a '${contextName}' provider.`,
      );
    }

    return value;
  }
</p>
github imodeljs / imodeljs / ui / framework / src / ui-framework / UiFramework.ts View on Github external
public static get statusBarManager(): StatusBarManager {
    // istanbul ignore next
    if (!UiFramework._statusBarManager)
      throw new UiError(UiFramework.loggerCategory(this), UiFramework._complaint);
    return UiFramework._statusBarManager;
  }
github imodeljs / imodeljs / ui / components / src / ui-components / UiComponents.ts View on Github external
public static get i18n(): I18N {
    if (!UiComponents._i18n)
      throw new UiError(UiComponents.loggerCategory(this), "UiComponents not initialized");
    return UiComponents._i18n;
  }
github imodeljs / imodeljs / ui / components / src / ui-components / tree / component / BeInspireTree.ts View on Github external
public async requestNodeLoad(parent: BeInspireTreeNode | undefined, index: number): Promise {
    if (!this._deferredLoadingHandler)
      throw new UiError(UiComponents.loggerCategory(this), `requestNodeLoad should only be called when pagination is enabled`);
    return this._deferredLoadingHandler.requestNodeLoad(parent, index);
  }