Re: Re: [svn-commits] r8515 - r3/trunk/binarycloud/node
Jean-Christophe Michel <jc.michel-/aRvmaKoZxNWk0Htik3J/[email protected]> Sat, 21 May 2005 12:35:50 +0200
| Newsgroups | gmane.comp.lib.binarycloud.devel |
|---|---|
| Message-ID | <[email protected]> |
B. Kamer wrote:
> hmm yes, a better idea would perhaps be can modify expand_path()
> function to throw an exception (see the @todo)?
>
> Just not sure if it allowed/good practice to throw exception here in
> procedural code.
>
> function expand_path($filename) {
> if ($filename{0} == '/')
> return $filename;
>
> $result = '';
> $pathArray = explode(PATH_SEPARATOR, get_include_path());
> foreach ($pathArray as $path)
> if (file_exists($path . '/' . $filename))
> $result = $path . '/' . $filename;
> + else {
> + bc_throw(new BcException(sprintf(/
> *#Exception.Binarycloud.FilepathNotExpandable#*/'This bc path (%s)
> could not be expanded to a full path', $filename),
> 'Exception.Binarycloud.PathNotExpandable'));
> + return false;
> + }
> }
> return $result;
> }
>
> and
>
> $expanded_path = expand_path($filename);
> if (!bc_catch($e)) {
> bc_throw(new BcException(sprintf(/
> *#Exception.Node.NdfFileMissing#*/'Node definition file (%s) does not
> exists.', $filename), 'Exception.Node.NdfFileMissing'));
> return false;
> }
>
> or (when it return false on error no throw)
>
> $expanded_path = expand_path($filename);
> if ($expanded_path === false) {
> bc_throw(new BcException(sprintf(/
> *#Exception.Node.NdfFileMissing#*/'Node definition file (%s) does not
> exists.', $filename), 'Exception.Node.NdfFileMissing'));
> return false;
> }
Seems the good way to me. Can you do it ?
--
Jean-Christophe Michel
_______________________________________________
dev mailing list
dev-PnctHDZWAvB/Cz2I37pSEPZ4XP/[email protected]
http://lists.binarycloud.com/mailman/listinfo/dev