Jump to content

  • Log In with Google      Sign In   
  • Create Account

Smacker_626

Member Since 26 Aug 2002
Offline Last Active Mar 20 2012 02:24 PM

Topics I've Started

Need help with try and catch blocks

04 March 2005 - 07:23 PM

I just started to use try and catch blocks for my new program. I made a class called CException that holds a long and 3 std::string's (Error Msg, Line, Filename, Function Name). I have the code like this
try
{
  // THROW_STR is a macro in CException.h along with THROW_NUM and THROW
  THROW_STR("THIS IS A TEST :P");
}
catch(CException e)
{
  // e.Format().c_str() wont work in the call to AddLog for some reason
  // Format returns a std::string with everything in it ;)
  string strError = e.Format();
  // AddLog of course adds the text to the log
  AddLog("\nException thrown!\n%s", strError.c_str());
}

ProgCleanup();
return g_iExitCode;

The compiler gives an error msg for THROW_STR(); "expected primary-expression before '(' token", I was going to say it gives an error msg for catch(CException e) too but I hit rebuild all again while I was writing this and it worked :-/. Also if I comment out the try / catch blocks and put
CException e("TEST", -1, __FILE__, __LINE__, __FUNCTION__);
AddLog("\nException thrown!\n%s", e.Format().c_str());

before them it gives me these errors "[Linker error] undefined reference to `CException::CException(std::string, long, std::string, long, std::string)'" "[Linker error] undefined reference to `CException::Format()'" "[Linker error] undefined reference to `CException::~CException()'" "[Linker error] undefined reference to `CException::~CException()'" yes it repeated that one twice and when I just use
try
{
  throw "TEST";
}
catch(string s)
{
  string strError = s;
  AddLog("\nException thrown!\n%s", strError.c_str());
}

ProgCleanup();
return g_iExitCode;

it won't put that text in the log but the text from ProgCleanup(); gets put in :-/, any help would be really nice :D I RARed and uploaded my code to > http://www.dragonruins.com/MyCode.rar You need v2.9 or > to UnRAR it (WinRAR - http://www.rarlabs.com/ of course :) ) I'm using Dev-CPP v4.9.9.1 - http://www.bloodshed.net/ (Use's gcc as the compiler) to compile everything. And how do you get URL's to work? Thanks ;-)

socket problem in visual basic

19 January 2005 - 03:48 PM

I'm trying to connect to a Web Server and do a simple request for a PHP script passing it a variable in the URL, I used Internet Explorer to connect to another one of my programs to get the HTTP headers, I can connect to the Server and send the headers but the Server never sends any data back, my requests show up in the log so I know it's getting through. I tried going through the "Hypertext Transfer Protocol -- HTTP/1.1" document at w3.org but all it helped me with is the Connection header. I compressed the VB project with WinRAR and uploaded it to my site http://www.dragonruins.com/Update_IP.rar Sorry if my code is messed up lol, I don't use VB much, i'm just trying to get this working so my friend won't have to give me his IP everytime he restart's so I can access his Web Server. Thanks for any help :) Edit: I don't know how to make URL's lol [Edited by - Smacker_626 on January 19, 2005 11:43:34 PM]

PARTNERS