<commit_before>import Promise from 'rsvp/promise';
import { ResolvedHandlerInfo } from './handler-info';
import { trigger, slice, log, promiseLabel } from './utils';

/**
  @private

  A Transition is a thennable (a promise-like object) that represents
  an attempt to transition to another route. It can be aborted, either
  explicitly via `abort` or by attempting another transition while a
  previous one is still underway. An aborted transition can also
  be `retry()`d later.
 */
function Transition(router, intent, state, error) {
  var transition = this;
  this.state = state || router.state;
  this.intent = intent;
  this.router = router;
  this.data = this.intent && this.intent.data || {};
  this.resolvedModels = {};
  this.queryParams = {};

  if (error) {
    this.promise = Promise.reject(error);
    return;
  }

  if (state) {
    this.params = state.params;
    this.queryParams = state.queryParams;
    this.handlerInfos = state.handlerInfos;

    var len = state.handlerInfos.length;
    if (len) {
      this.targetName = state.handlerInfos[len-1].name;
    }

    for (var i = 0; i < len; ++i) {
      var handlerInfo = state.handlerInfos[i];

      // TODO: this all seems hacky
      if (!handlerInfo.isResolved) { break; }
      this.pivotHandler = handlerInfo.handler;
    }

    this.sequence = Transition.currentSequence++;
    this.promise = state.resolve(checkForAbort, this)['catch'](function(result) {
      if (result.wasAborted || transition.isAborted) {
        return Promise.reject(logAbort(transition));
      } else {<commit_msg>Allow synchronous detection of transition errors<commit_after>import Promise from 'rsvp/promise';
import { ResolvedHandlerInfo } from './handler-info';
import { trigger, slice, log, promiseLabel } from './utils';

/**
  @private

  A Transition is a thennable (a promise-like object) that represents
  an attempt to transition to another route. It can be aborted, either
  explicitly via `abort` or by attempting another transition while a
  previous one is still underway. An aborted transition can also
  be `retry()`d later.
 */
function Transition(router, intent, state, error) {
  var transition = this;
  this.state = state || router.state;
  this.intent = intent;
  this.router = router;
  this.data = this.intent && this.intent.data || {};
  this.resolvedModels = {};
  this.queryParams = {};

  if (error) {
    this.promise = Promise.reject(error);
    this.error = error;
    return;
  }

  if (state) {
    this.params = state.params;
    this.queryParams = state.queryParams;
    this.handlerInfos = state.handlerInfos;

    var len = state.handlerInfos.length;
    if (len) {
      this.targetName = state.handlerInfos[len-1].name;
    }

    for (var i = 0; i < len; ++i) {
      var handlerInfo = state.handlerInfos[i];

      // TODO: this all seems hacky
      if (!handlerInfo.isResolved) { break; }
      this.pivotHandler = handlerInfo.handler;
    }

    this.sequence = Transition.currentSequence++;
    this.promise = state.resolve(checkForAbort, this)['catch'](function(result) {
      if (result.wasAborted || transition.isAborted) {
        return Promise.reject(logAbort(transition));
      } else {
{'fraction_non_alphanumeric': 0.12112676056338029, 'fraction_numerical': 0.0012519561815336462, 'mean_word_length': 3.284182305630027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4789559', 'n_tokens_mistral': 975, 'n_tokens_neox': 955, 'n_words': 271}