var util = require('util')
var arrayToMap = require('./array-to-map')

/**
 * Available types of errors
 */
var types = arrayToMap(['UnknownOption', 'InvalidKey'])

/**
 * Custom message for unknown cli option
 * @constructor UknownOptionError
 * @param {String} message? error message
 */
function UnknownOptionError(message) {
	this.type = types.UnknownOption
	this.message = message
}

// inherits builtin Error
util.inherits(UnknownOptionError, Error)

/**
 * Custom error for invalid cli option
 * @constructor InvalidKeyError
 * @param {String} message?
 */
function InvalidKeyError(message) {
	this.type = types.InvalidKey
	this.message = message
}

util.inherits(InvalidKeyError, Error)

module.exports = {
	errorTypes: types,
	InvalidKeyError: InvalidKeyError,
	UnknownOptionError: UnknownOptionError
}


@@ -1,34 +1,24 @@
-var util = require('util')%0Avar
+'use strict';%0A%0Aconst
  arr
@@ -41,23 +41,30 @@
 e('.
-/array-to-map')
+./-funcs').arrayToMap;
 %0A%0A/*
@@ -102,11 +102,13 @@
  */%0A
-var
+const
  typ
@@ -155,16 +155,17 @@
 idKey'%5D)
+;
 %0A%0A/**%0A *
@@ -169,79 +169,27 @@
 %0A * 
-Custom message for unknown cli option%0A * @constructor UknownOptionError
+Unknown CLI option.
 %0A * 
@@ -205,23 +205,26 @@
 tring%7D m
-essage?
+sg  Custom
  error m
@@ -229,29 +229,27 @@
  message
+.
 %0A */%0A
-function
+class
  Unknown
@@ -255,36 +255,62 @@
 nOptionError
-(message
+ extends Error %7B%0A%09constructor(msg
 ) %7B%0A
+%09
 %09this.type =
@@ -329,17 +329,19 @@
 wnOption
+;
 %0A
+%09
 %09this.me
@@ -353,84 +353,16 @@
  = m
-essage%0A%7D%0A%0A// inherits builtin Error%0Autil.inherits(UnknownOptionError, Error)
+sg;%0A%09%7D%0A%7D
 %0A%0A/*
@@ -395,11 +395,11 @@
 lid 
-cli
+CLI
  opt
@@ -410,104 +410,90 @@
  * @
-constructor InvalidKeyError%0A * @param %7BString%7D message?%0A */%0Afunction InvalidKeyError(message
+param %7BString%7D msg%0A */%0Aclass InvalidKeyError extends Error %7B%0A%09constructor(msg
 ) %7B%0A
+%09
 %09thi
@@ -517,17 +517,19 @@
 validKey
-%0A
+;%0A%09
 %09this.me
@@ -541,55 +541,16 @@
  = m
-essage%0A%7D%0A%0Autil.inherits(InvalidKeyError, Error)
+sg;%0A%09%7D%0A%7D
 %0A%0Amo
@@ -662,10 +662,10 @@
 nError%0A%7D
-%0A
+;
 %0A

update utils/errors; use classes