<commit_before>import { Injectable }    from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { Subject } from 'rxjs/Subject';

import { ApiErrorHandle } from '../../shared/api-error-handle';

@Injectable()
export class ApiErrorService {

  // private properties
  private errorSource: Subject<ApiErrorHandle>;

  // public properties
  readonly error$: Observable<ApiErrorHandle>;

  // public methods

  constructor() {
    this.errorSource = new Subject<ApiErrorHandle>();
    this.error$ = this.errorSource.asObservable();
  };

  handleError(observable: Observable<Response>): Observable<Response> {
    return Observable.create((observer : Observer<Response>) => this.try(observable, observer));
  }

  // private methods

  try(observable: Observable<Response>, observer: Observer<Response>) {
    let service = this;
    observable.subscribe(
      (res: Response) => {
        observer.next(res);
        observer.complete();
      },
      (error: any) => {
        console.log('An error occurred', error); // for debugging

        let errMsg = ""
        if (error.statusText) {
            errMsg = ` - ${error.statusText}`;
        }
        let errStatus = error.status ? `${error.status}` : "Could not connect";
        errMsg = `API error: ${errStatus}${errMsg}`;

        let retryFn = function() {
          service.try(observable, observer);
        };

        service.errorSource.next(new ApiErrorHandle(errMsg, observer, retryFn));

      }
    );
  }

}<commit_msg>Made private functions truly private<commit_after>import { Injectable }    from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { Subject } from 'rxjs/Subject';

import { ApiErrorHandle } from '../../shared/api-error-handle';

@Injectable()
export class ApiErrorService {

  // private properties
  private errorSource: Subject<ApiErrorHandle>;

  // public properties
  readonly error$: Observable<ApiErrorHandle>;

  // public methods

  constructor() {
    this.errorSource = new Subject<ApiErrorHandle>();
    this.error$ = this.errorSource.asObservable();
  };

  handleError(observable: Observable<Response>): Observable<Response> {
    return Observable.create((observer : Observer<Response>) => this.try(observable, observer));
  }

  // private methods

  private try(observable: Observable<Response>, observer: Observer<Response>) {
    observable.subscribe(
      (res: Response) => {
        observer.next(res);
        observer.complete();
      },
      (error: any) => this.onErrorFn(observable, observer, error)
      );
  }

  private onErrorFn(observable: Observable<Response>, observer: Observer<Response>, error: any) {
    console.log('An error occurred', error); // for debugging

    let errMsg = ""
    if (error.statusText) {
        errMsg = ` - ${error.statusText}`;
    }
    let errStatus = error.status ? `${error.status}` : "Could not connect";
    errMsg = `API error: ${errStatus}${errMsg}`;

    let retryFn = () => this.try(observable, observer);

    this.errorSource.next(new ApiErrorHandle(errMsg, observer, retryFn));

  }

}
{'fraction_non_alphanumeric': 0.14246323529411764, 'fraction_numerical': 0.0, 'mean_word_length': 3.406207827260459, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5815977', 'n_tokens_mistral': 939, 'n_tokens_neox': 920, 'n_words': 215}