lua-users home
lua-l archive

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


On Thursday 16 February 2006 22:15, Chris wrote:
[...]
> That I have thought about.  There are a couple problems with this.  One is
> that from the programmer's point of view it doesn't make a lot of sense and
> is extra work they need to do just to return an error code.

Rather than use non-printable characters, use could always use decimal.

"100 File not found"
"100 File 'settings.conf' not found"
"100 Fiche ne trouve pas"
"101 Directory not found"
"102 etc"

function errorcode(s)
	return tonumber(string.sub(s, 1, 3))
end

Hey, if it's good enough for SMTP, NNTP, HTTP, and most of the rest of the 
internet infrastructure... this has the advantage that (a) it's human 
readable; (b) it's machine readable; (c) it's localisable; (d) it's 
customisable; (e) with a slightly more intelligent errorcode() function it's 
even backwards compatible...

-- 
+- David Given --McQ-+ 
|  dg@cowlark.com    | "I tried Zen once, but I understood it." ---
| (dg@tao-group.com) | Anonymous
+- www.cowlark.com --+ 

Attachment: pgpFjMOce1mwC.pgp
Description: PGP signature