This is a general computer question, but I'm writing in PHP so I'll
post this to comp.lang.php.
I've been writing a content management system. I've a Singleton object
that keeps track of all errors and stores them in an array. As things
work right now, I write out each error message individually. I'm
thinking that as the code grows, this system will not continue to
scale. Right now my software consists of 1.4 megs of PHP code. I don't
know how many error messages there are, but a reasonable guess is 1800
(I've 900 functions and classes in 900 files, and I'm guessing two
error messages in each, on average). You can see an example of what I
mean below, setFilterObject is a fairly standard class method, with 3
possible error messages when things go wrong. As you can see, I've
written out each error message in English.
There are a number of problems with this. One is that at some point I'd
like to internationalize the software, which I assume means making it
easy to rewrite the error messages in other languages. Therefore, I
assume I'm making a mistake by hard-coding them as English. The other
problem is that it takes a lot of time to write out these error
messages, and the error messages constitute a growing percent of the
code.
I know that as software project grow some system is usually put in
place to regulate error messages. Can anyone point me to tutorials or
books that have good info on this?
function setFilterObject($filterObjectName=false) {
$imported = $this->controllerForAll->import("IntfFilter",
"ExteriorFilter");
if ($imported) {
if ($filterObjectName) {
$filterObjectName = ucfirst($filterObjectName);
$filterObjectName = "Filter".$filterObjectName;
$this->filterObjectName = $filterObjectName;
$this->filterObject = &
$this->controllerForAll->getObject($filterObjectName,
"ExteriorFetch");
if (is_object($this->filterObject)) {
return true;
} else {
$this->resultsObject->error("In the command setFilterObject(), in
ExteriorFilter, we expected to get an object called
'$filterObjectName', but we could not find it.", "ExteriorFilter");
}
} else {
$this->resultsObject->error("In the command setFilterObject(), in
ExteriorFilter, we expected to be told the name of a filter object we
should look for, but we were given an empty string.", "ExteriorFetch");
}
} else {
$this->resultsObject->error("In setFilterObject(), in
ExteriorFilter, we tried to import the interface IntfFilter, but we
were unable to.", "ExteriorFilter");
}
}