Repository: atom/atom
File: src/state-store.js (JavaScript)

Code before:
    this.connected = false;
    this.databaseName = databaseName;
    this.version = version;
  }

  get dbPromise() {
    if (!this._dbPromise) {
      this._dbPromise = new Promise(resolve => {
        const dbOpenRequest = indexedDB.open(this.databaseName, this.version);
        dbOpenRequest.onupgradeneeded = event => {
          let db = event.target.result;
          db.onerror = error => {
            atom.notifications.addError('Error loading database', {
              stack: new Error('Error loading database').stack,
              dismissable: true
            });
            console.error('Error loading database', error);
          };
          db.createObjectStore('states');
        };
        dbOpenRequest.onsuccess = () => {
          this.connected = true;
          resolve(dbOpenRequest.result);
        };
        dbOpenRequest.onerror = error => {
          atom.notifications.addError('Could not connect to indexedDB', {
            stack: new Error('Could not connect to indexedDB').stack,
            dismissable: true
          });
          console.error('Could not connect to indexedDB', error);
          this.connected = false;
          resolve(null);
        };
      });
    }

    return this._dbPromise;
  }

  isConnected() {
    return this.connected;
  }

  connect() {
    return this.dbPromise.then(db => !!db);
  }

  save(key, value) {
    return new Promise((resolve, reject) => {
      this.dbPromise.then(db => {
        if (db == null) return resolve();

Review comment (suggestion):
```suggestion
          atom.notifications.addFatalError('Could not connect to indexedDB', {
```

Code after:
    this.connected = false;
    this.databaseName = databaseName;
    this.version = version;
  }

  get dbPromise() {
    if (!this._dbPromise) {
      this._dbPromise = new Promise(resolve => {
        const dbOpenRequest = indexedDB.open(this.databaseName, this.version);
        dbOpenRequest.onupgradeneeded = event => {
          let db = event.target.result;
          db.onerror = error => {
            atom.notifications.addFatalError('Error loading database', {
              stack: new Error('Error loading database').stack,
              dismissable: true
            });
            console.error('Error loading database', error);
          };
          db.createObjectStore('states');
        };
        dbOpenRequest.onsuccess = () => {
          this.connected = true;
          resolve(dbOpenRequest.result);
        };
        dbOpenRequest.onerror = error => {
          atom.notifications.addFatalError('Could not connect to indexedDB', {
            stack: new Error('Could not connect to indexedDB').stack,
            dismissable: true
          });
          console.error('Could not connect to indexedDB', error);
          this.connected = false;
          resolve(null);
        };
      });
    }

    return this._dbPromise;
  }

  isConnected() {
    return this.connected;
  }

  connect() {
    return this.dbPromise.then(db => !!db);
  }

  save(key, value) {
    return new Promise((resolve, reject) => {
      this.dbPromise.then(db => {
        if (db == null) return resolve();