Skip to content

Commit

Permalink
fixed commit count/sha versioning display
Browse files Browse the repository at this point in the history
  • Loading branch information
tihmstar committed Nov 15, 2020
1 parent f571dc2 commit f5cb2b1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
*.DS_Store
*.patch
*.diff
*.o
*.a
*.la
*.lo
aclocal.m4
autom4te.cache
compile
config.*
configure
depcomp
*/.deps
*/.libs
Makefile
Makefile.in
install-sh
libtool
ltmain.sh
m4
missing
stamp-h1
xcuserdata
Build
Index
stamp-h2
*.pc
img4tool/img4tool
include/img4tool/img4tool.hpp
6 changes: 4 additions & 2 deletions include/libgeneral/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

namespace tihmstar {
class exception : public std::exception{
int _code;
const char *_commit_count_str;
const char *_commit_sha_str;
int _line;
std::string _filename;
char *_err;
public:
exception(int code, const char *filename, const char *err ...);
exception(const char *commit_count_str, const char *commit_sha_str, int line, const char *filename, const char *err ...);

//custom error can be used
const char *what();
Expand Down
14 changes: 7 additions & 7 deletions include/libgeneral/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@
#ifdef EXCEPT_ASSURE
#include "exception.hpp"
//assure cpp
# define assure(cond) do{ if ((cond) == 0) throw tihmstar::EXPECTIONNAME(__LINE__, __FILE__, "assure failed"); } while(0)
# define retassure(cond, errstr ...) do{ if ((cond) == 0) throw tihmstar::EXPECTIONNAME(__LINE__,__FILE__,errstr); } while(0)
# define customassure(cond, custom_except) do{ if ((cond) == 0) throw tihmstar::custom_except(__LINE__, __FILE__, "assure failed"); } while(0)
# define retcustomassure(cond, custom_except,errstr ...) do{ if ((cond) == 0) throw tihmstar::custom_except(__LINE__, __FILE__, errstr); } while(0)
# define reterror(errstr ...) do{ throw tihmstar::EXPECTIONNAME(__LINE__, __FILE__, errstr); } while(0)
# define retcustomerror(custom_except,errstr ...) do{ throw tihmstar::custom_except(__LINE__, __FILE__, errstr); } while(0)
# define assure(cond) do{ if ((cond) == 0) throw tihmstar::EXPECTIONNAME(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__, __FILE__, "assure failed"); } while(0)
# define retassure(cond, errstr ...) do{ if ((cond) == 0) throw tihmstar::EXPECTIONNAME(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__,__FILE__,errstr); } while(0)
# define customassure(cond, custom_except) do{ if ((cond) == 0) throw tihmstar::custom_except(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__, __FILE__, "assure failed"); } while(0)
# define retcustomassure(cond, custom_except,errstr ...) do{ if ((cond) == 0) throw tihmstar::custom_except(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__, __FILE__, errstr); } while(0)
# define reterror(errstr ...) do{ throw tihmstar::EXPECTIONNAME(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__, __FILE__, errstr); } while(0)
# define retcustomerror(custom_except,errstr ...) do{ throw tihmstar::custom_except(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__, __FILE__, errstr); } while(0)
# define doassure(cond,code) do {if (!(cond)){(code);assure(cond);}} while(0)
//mach assures
# define assureMach(kernRet) do {kern_return_t __kret = kernRet; if (__kret) throw tihmstar::EXPECTIONNAME(__LINE__, __FILE__, "assure failed");} while(0)
# define assureMach(kernRet) do {kern_return_t __kret = kernRet; if (__kret) throw tihmstar::EXPECTIONNAME(VERSION_COMMIT_COUNT, VERSION_COMMIT_SHA, __LINE__, __FILE__, "assure failed");} while(0)
# define assureMachclean(kernRet) do {kern_return_t __kret = kernRet; if (__kret){clean();assureMach(__kret);}} while(0)
# define assureCatchClean(code) do {try { code; } catch (EXPECTIONNAME &e) { clean(); throw; }} while (0)
# define assureNoDoublethrow(code) \
Expand Down
16 changes: 9 additions & 7 deletions libgeneral/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

using namespace tihmstar;

exception::exception(int code, const char *filename, const char *err ...) :
_code(code),
exception::exception(const char *commit_count_str, const char *commit_sha_str, int line, const char *filename, const char *err ...) :
_commit_count_str(commit_count_str),
_commit_sha_str(commit_sha_str),
_line(line),
_filename(filename),
_err(NULL)
{
Expand All @@ -29,25 +31,25 @@ const char *exception::what(){
}

int exception::code() const{
return (_code << 16) | (int)(_filename.size());
return (_line << 16) | (int)(_filename.size());
}

void exception::dump() const{
printf("[exception]:\n");
printf("what=%s\n",_err);
printf("code=%d\n",code());
printf("line=%d\n",_code);
printf("line=%d\n",_line);
printf("file=%s\n",_filename.c_str());
printf("commit count=%s:\n",build_commit_count().c_str());
printf("commit sha =%s:\n",build_commit_sha().c_str());
}

std::string exception::build_commit_count() const {
return VERSION_COMMIT_COUNT;
return _commit_count_str;
};

std::string exception::build_commit_sha() const{
return VERSION_COMMIT_SHA;
std::string exception::build_commit_sha() const {
return _commit_sha_str;
};

exception::~exception(){
Expand Down

0 comments on commit f5cb2b1

Please sign in to comment.