<commit_before>require 'json'

module ZSS
  class Error < ::StandardError

    attr_reader :code, :developer_message, :user_message

    def initialize(code, payload)
      @code = code.to_i
      @developer_message = payload.developerMessage
      @user_message = payload.userMessage
      super @developer_message
      set_backtrace caller
    end

    def self.[](code)
      data = get_errors[code.to_s]
      Error.new(code.to_i, data.body)
    end

    private

    def self.get_errors
      @errors ||= begin
        path = File.join(
          File.dirname(File.absolute_path(__FILE__)),
          'errors.json'
        )
        file = File.read(path)
        Hashie::Mash.new(JSON.parse(file))
      end
    end

  end
end
<commit_msg>develop message can be write to override default message and give extra info<commit_after>require 'json'

module ZSS
  class Error < ::StandardError

    attr_reader :code, :user_message
    attr_accessor :developer_message

    def initialize(code, payload)
      @code = code.to_i
      @developer_message = payload.developerMessage
      @user_message = payload.userMessage
      super @developer_message
      set_backtrace caller
    end

    def self.[](code)
      data = get_errors[code.to_s]
      Error.new(code.to_i, data.body)
    end

    private

    def self.get_errors
      @errors ||= begin
        path = File.join(
          File.dirname(File.absolute_path(__FILE__)),
          'errors.json'
        )
        file = File.read(path)
        Hashie::Mash.new(JSON.parse(file))
      end
    end

  end
end

{'fraction_non_alphanumeric': 0.09096692111959287, 'fraction_numerical': 0.0, 'mean_word_length': 2.4047619047619047, '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': '4178625', 'n_tokens_mistral': 500, 'n_tokens_neox': 477, 'n_words': 109}