Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sife-shuo committed Aug 21, 2023
1 parent 4da6412 commit 401a2a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ TYPE TYPESIZE::_to_char(string h){

template <typename S>
void printv(int i,int a,int b,S w){
printf("[ Out ] >> ");
cout<<OUT;
cout<<"["<<i<<":"<<b*i<<'-'<<b*(i+1)<<"B]:"<<w<<endl;
return ;
}
Expand Down
10 changes: 8 additions & 2 deletions command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ void usage(){
if(!to.fflag){
printf("-");
}
printf("[ Out ] >> ");
cout<<OUT;
cout<<(to.main)<<endl;
}else if(u=="p"){//pseudocode
string ftype,ttype;
cin>>ftype>>ttype;
TYPESIZE::turn(ftype,ttype);
try{
TYPESIZE::turn(ftype,ttype);
}catch(int err){
if(err==-1){
cout<<OUT<<"Wrong TypeName\n";
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions dem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ typedef struct NUM_DEV {
std::string main;
unsigned int dema;
} NUM;
char OUT[]={"[ Out ] >> "};
char IN[]={"[ In ] << "};

using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(){
TYPESIZE::turn(t,j,w);*/
//cout<<h[0]<<endl<<h[1];
while(true){
printf("[ In ] << ");
cout<<IN;
//string h;
//getline(cin,h);
usage();
Expand Down

0 comments on commit 401a2a7

Please sign in to comment.