gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exception handling with NSURL


From: Philippe Roussel
Subject: Exception handling with NSURL
Date: Thu, 06 Dec 2007 09:51:29 +0100

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:address@hidden, 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 STACK:("{pointer = 0xb78847be;}", "{pointer =
0xb78846f6;}", "{pointer = 0xb793e50f;}", "{pointer = 0xb793dc1c;}",
"{pointer = 0xb793d65d;}", "{pointer = 0x805e07f;}", "{pointer =
0xb78bb181;}", "{pointer = 0xb78bb708;}", "{pointer = 0xb7c25d88;}",
"{pointer = 0xb7d1a37a;}", "{pointer = 0xb78bb181;}", "{pointer =
0xb78bb708;}", "{pointer = 0xb78bb5bd;}", "{pointer = 0xb7d8e7ab;}",
"{pointer = 0xb7d8d0bc;}", "{pointer = 0xb7c6ac34;}", "{pointer =
0xb7c6a8b4;}", "{pointer = 0xb7cc128c;}", "{pointer = 0xb7d974c2;}",
"{pointer = 0xb7d45ab2;}", "{pointer = 0xb7bc4f4a;}", "{pointer =
0xb7bc476b;}", "{pointer = 0xb7bc4306;}", "{pointer = 0x805deb8;}",
"{pointer = 0x805f741;}", "{pointer = 0x805d61a;}", "{pointer =
0xb72e3437;}", "{pointer = 0xb7975496;}", "{pointer = 0xb7975865;}",
"{pointer = 0xb7bc571a;}", "{pointer = 0xb7c26431;}", "{pointer =
0xb7bfca65;}", "{pointer = 0xb7bf68b0;}", "{pointer = 0xb7c2687b;}",
"{pointer = 0xb7bf2555;}", "{pointer = 0xb7d45ab2;}", "{pointer =
0xb7bc4f4a;}", "{pointer = 0xb7bc3b38;}", "{pointer = 0xb7ba6151;}",
"{pointer = 0x80670ca;}", "{pointer = 0xb75f4050;}", "{pointer =
0x804b2f1;}")

Am I doing something wrong ?

Thanks,
Philippe






reply via email to

[Prev in Thread] Current Thread [Next in Thread]