<commit_before>import { UniqueViolationError } from 'objection-db-errors'
import { FeathersError, Conflict, GeneralError } from '@feathersjs/errors'

const errorHandler = (ctx) => {
  if (!ctx.error) {
    return
  }
  if (ctx.error instanceof UniqueViolationError) {
    const error = new Conflict('Unique Violation Error')
    error.errors = ctx.error.columns
    throw error
  }
  if (ctx.error instanceof FeathersError) {
    throw ctx.error
  }
  throw new GeneralError('unknown error', ctx.error.data)
}

export default errorHandler<commit_msg>Add workaround to display DB error log.<commit_after>import { UniqueViolationError } from 'objection-db-errors'
import { FeathersError, Conflict, GeneralError } from '@feathersjs/errors'
import _ from 'lodash'

const errorHandler = (ctx) => {
  if (!ctx.error) {
    return
  }
  // FIXME currently using console.log to display DB errors
  // as app.error doesn't display it
  // eslint-disable-next-line no-console
  console.log(_.omit(ctx.error, ['hook']))
  if (ctx.error instanceof UniqueViolationError) {
    const error = new Conflict('Unique Violation Error')
    error.errors = ctx.error.columns
    throw error
  }
  if (ctx.error instanceof FeathersError) {
    throw ctx.error
  }
  throw new GeneralError('unknown error', ctx.error.data)
}

export default errorHandler
{'fraction_non_alphanumeric': 0.10676691729323308, 'fraction_numerical': 0.0, 'mean_word_length': 3.9479553903345725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1270846', 'n_tokens_mistral': 403, 'n_tokens_neox': 401, 'n_words': 113}