From 401a2a7e61a6b048e42a144d89bc83a50f5b01dc Mon Sep 17 00:00:00 2001 From: Sife-shuo <88375951+Sife-shuo@users.noreply.github.com> Date: Mon, 21 Aug 2023 08:04:30 +0800 Subject: [PATCH] Add error handling --- bit.hpp | 4 ++-- command.hpp | 10 ++++++++-- dem.hpp | 2 ++ main.cpp | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bit.hpp b/bit.hpp index d39c0fa..bbbeece 100644 --- a/bit.hpp +++ b/bit.hpp @@ -91,7 +91,7 @@ int TYPESIZE::g(string h){ else if(h=="ld"){return sizeof(long double);} //else if(h=="w"){return sizeof(wchar_t);} else{ - throw("Wrong TypeName"); + throw -1; } return 0; } @@ -136,7 +136,7 @@ TYPE TYPESIZE::_to_char(string h){ template void printv(int i,int a,int b,S w){ - printf("[ Out ] >> "); + cout<> "); + cout<>ftype>>ttype; - TYPESIZE::turn(ftype,ttype); + try{ + TYPESIZE::turn(ftype,ttype); + }catch(int err){ + if(err==-1){ + cout<> "}; +char IN[]={"[ In ] << "}; using namespace std; diff --git a/main.cpp b/main.cpp index 542cd28..c9da915 100644 --- a/main.cpp +++ b/main.cpp @@ -19,7 +19,7 @@ int main(){ TYPESIZE::turn(t,j,w);*/ //cout<