<commit_before>import R from 'ramda'

import { makeDebugger, $solver, asyncRes, ERR, EVENT, isObject } from 'utils'

import SR71 from 'utils/async/sr71'

const sr71$ = new SR71({
  resv_event: [EVENT.ERR_RESCUE],
})
let sub$ = null
let store = null

/* eslint-disable-next-line */
const debug = makeDebugger('L:ErrorBox')

export const onClose = () => store.markState({ show: false })

const classifyGQErrors = errors => {
  if (!Array.isArray(errors)) {
    return debug('invalid errors: ', errors)
  }

  if (R.has('path', errors[0])) {
    if (isObject(errors[0].message)) {
      return store.markState({
        graphqlType: 'changeset',
        changesetError: errors,
      })
    }
    return store.markState({
      graphqlType: 'custom',
      customError: errors,
    })
  }

  store.markState({ graphqlType: 'parse', parseError: errors })
}

export const hide = () => {
  store.markState({ show: false })
}

// ###############################
// Data & Error handlers
// ###############################

const DataSolver = [
  {
    match: asyncRes(EVENT.ERR_RESCUE),
    action: res => {
      const { type, data: { operation, details, path } } = res[EVENT.ERR_RESCUE]

      switch (type) {
        case ERR.GRAPHQL:
          classifyGQErrors(details)
          break<commit_msg>style: fmt<commit_after>import R from 'ramda'

import { makeDebugger, $solver, asyncRes, ERR, EVENT, isObject } from 'utils'

import SR71 from 'utils/async/sr71'

const sr71$ = new SR71({
  resv_event: [EVENT.ERR_RESCUE],
})
let sub$ = null
let store = null

/* eslint-disable-next-line */
const debug = makeDebugger('L:ErrorBox')

export const onClose = () => store.markState({ show: false })

const classifyGQErrors = errors => {
  if (!Array.isArray(errors)) {
    return debug('invalid errors: ', errors)
  }

  if (R.has('path', errors[0])) {
    if (isObject(errors[0].message)) {
      return store.markState({
        graphqlType: 'changeset',
        changesetError: errors,
      })
    }
    return store.markState({
      graphqlType: 'custom',
      customError: errors,
    })
  }

  store.markState({ graphqlType: 'parse', parseError: errors })
}

export const hide = () => {
  store.markState({ show: false })
}

// ###############################
// Data & Error handlers
// ###############################

const DataSolver = [
  {
    match: asyncRes(EVENT.ERR_RESCUE),
    action: res => {
      const {
        type,
        data: { operation, details, path },
      } = res[EVENT.ERR_RESCUE]

      switch (type) {
        case ERR.GRAPHQL:
          classifyGQErrors(details)
          break
{'fraction_non_alphanumeric': 0.18634969325153375, 'fraction_numerical': 0.007668711656441718, 'mean_word_length': 3.0765625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4864463', 'n_tokens_mistral': 859, 'n_tokens_neox': 846, 'n_words': 196}