#ifndef GITTEH_ERROR_H
#define GITTEH_ERROR_H

#include "gitteh.h"

#define ADD_GIT_ERROR_CONSTANT(ERR)											\
	errorsObj->Set(String::New(""#ERR), Integer::New(ERR));

namespace gitteh {
	static inline void ErrorInit(Handle<Object> target) {
		HandleScope scope;

		Handle<Object> errorsObj = Object::New();
		target->Set(String::New("error"), errorsObj);

		ADD_GIT_ERROR_CONSTANT(GIT_SUCCESS);
		ADD_GIT_ERROR_CONSTANT(GIT_ERROR);
		ADD_GIT_ERROR_CONSTANT(GIT_ENOTOID);
		ADD_GIT_ERROR_CONSTANT(GIT_ENOTFOUND);
		ADD_GIT_ERROR_CONSTANT(GIT_ENOMEM);
		ADD_GIT_ERROR_CONSTANT(GIT_EOSERR);
		ADD_GIT_ERROR_CONSTANT(GIT_EOBJTYPE);
		ADD_GIT_ERROR_CONSTANT(GIT_EOBJCORRUPTED);
		ADD_GIT_ERROR_CONSTANT(GIT_ENOTAREPO);
		ADD_GIT_ERROR_CONSTANT(GIT_EINVALIDTYPE);
		ADD_GIT_ERROR_CONSTANT(GIT_EMISSINGOBJDATA);
		ADD_GIT_ERROR_CONSTANT(GIT_EPACKCORRUPTED);
		ADD_GIT_ERROR_CONSTANT(GIT_EFLOCKFAIL);
		ADD_GIT_ERROR_CONSTANT(GIT_EZLIB);
		ADD_GIT_ERROR_CONSTANT(GIT_EBUSY);
		ADD_GIT_ERROR_CONSTANT(GIT_EBAREINDEX);
	}
}

#endif // GITTEH_ERROR_H
