message: Throw IModelError instead of Error
diff: /*---------------------------------------------------------------------------------------------
  | $Copyright: (c) 2017 Bentley Systems, Incorporated. All rights reserved. $
  *--------------------------------------------------------------------------------------------*/
  +import { IModelError, IModelStatus } from "../common/IModelError";
  +import { Logger } from "../common/Logger";
  import { ClassRegistry } from "./ClassRegistry";
  import { EntityCtor } from "./Entity";
  import { IModelDb } from "./IModelDb";
  @@ -24,17 +26,19 @@ export class Schema {
  export class Schemas {
  private static _registeredSchemas: { [key: string]: Schema; } = {};
  - /** Register a schema prior to using it. */
  + /** Register a schema prior to using it.
  + * @throws [[IModelError]] if a schema of the same name is already registered.
  + */
  public static registerSchema(schema: Schema) {
  const key = schema.name.toLowerCase();
  if (Schemas.getRegisteredSchema(key))
  - throw new Error("schema " + key + " is already registered");
  + throw new IModelError(IModelStatus.DuplicateName, "Schema \"" + key + "\" is already registered", Logger.logWarning);
  Schemas._registeredSchemas[key] = schema;
  }
  /** Look up a previously registered schema
  * @param schemaName The name of the schema
  - * @returns the previously registered schema or undefined if not registered.
  + * @returns the previously registered schema or `undefined` if not registered.
  */
  public static getRegisteredSchema(schemaName: string): Schema | undefined {
  return Schemas._registeredSchemas[schemaName.toLowerCase()];
  