On 2007-12-06 08:51:29 +0000 Philippe Roussel <[EMAIL PROTECTED]> wrote:

Hi all,

I'm trying to verify a string is a valid URL with the following :

- (void)controlTextDidChange:(NSNotification *)notification
{
  NS_DURING
    {
      NSURL *storeUrl = [NSURL URLWithString:[url stringValue]];
      [ok setEnabled:(storeUrl != nil)];
    }
  NS_HANDLER
    {
      NSLog([localException name]);
      [ok setEnabled:NO];
    }
  NS_ENDHANDLER
}

When I enter an URL of the form http://user:[EMAIL PROTECTED], an exception is
raised (see below) when starting to enter the password because NSURL is
expecting a numeric port (as in http://host:port). The thing is, the
exception isn't catched by NS_HANDLER (NSLog is never called) and the
application coredumps when I enter another caracter.

<NSException: 0x8357318> NAME:NSGenericException REASON:illegal
character in port part

<snip>

Am I doing something wrong ?

My guess is that you are misinterpreting what's happening.

Probably the reason the NSLog() in the exception handler is not called is because the handler is not called because the exception is not ocurring in this piece of code. The exception message 'illegal character in port part' does not correspond to a URL for the form 'http://user:[EMAIL PROTECTED]' because such a URL has no port part, so it's presumably being raised because some otyher URL used elsewhere in the program has a port part containing an illegal character.



_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to