Пример #1
0
bool
XIncludeUtils::reportError(const DOMNode* const    /*errorNode*/
                              , XMLErrs::Codes errorType
                              , const XMLCh*   const    errorMsg
                              , const XMLCh * const href)
{
    bool toContinueProcess = true;   /* default value for no error handler */

    const XMLCh* const                    systemId = href;
    const XMLCh* const                    publicId = href;
    /* TODO - look these up somehow? */
    const XMLFileLoc                 lineNum = 0;
    const XMLFileLoc                 colNum = 0;

    if (fErrorReporter)
    {
        // Load the message into a local for display
        const XMLSize_t msgSize = 1023;
        XMLCh errText[msgSize + 1];

        /* TODO - investigate whether this is complete */
        XMLMsgLoader  *errMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
        if (errorMsg == NULL){
            if (errMsgLoader->loadMsg(errorType, errText, msgSize))
            {
                    // <TBD> Probably should load a default msg here
            }
        } else {
            if (errMsgLoader->loadMsg(errorType, errText, msgSize, errorMsg))
            {
                    // <TBD> Probably should load a default msg here
            }
        }

        fErrorReporter->error(errorType
                              , XMLUni::fgXMLErrDomain    //fgXMLErrDomain
                              , XMLErrs::errorType(errorType)
                              , errText
                              , systemId
                              , publicId
                              , lineNum
                              , colNum);
    }

    if (XMLErrs::isFatal(errorType))
        fErrorCount++;

    return toContinueProcess;
}
void XSDErrorReporter::emitError(const unsigned int toEmit,
                                 const XMLCh* const msgDomain,
                                 const Locator* const aLocator,
                                 const XMLCh* const text1,
                                 const XMLCh* const text2,
                                 const XMLCh* const text3,
                                 const XMLCh* const text4,
                                 MemoryManager* const manager)
{
    // Bump the error count if it is not a warning
//    if (XMLErrs::errorType(toEmit) != XMLErrorReporter::ErrType_Warning)
//        incrementErrorCount();

    //
    //  Load the message into alocal and replace any tokens found in
    //  the text.
    //
    const XMLSize_t maxChars = 2047;
    XMLCh errText[maxChars + 1];
    XMLMsgLoader* msgLoader = gErrMsgLoader;
    XMLErrorReporter::ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) toEmit);

    if (XMLString::equals(msgDomain, XMLUni::fgValidityDomain)) {

        errType = XMLValid::errorType((XMLValid::Codes) toEmit);
        msgLoader = gValidMsgLoader;
    }

    if (!msgLoader->loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4, manager))
    {
        // <TBD> Should probably load a default message here
    }

    if (fErrorReporter)
        fErrorReporter->error(toEmit, msgDomain, errType, errText, aLocator->getSystemId(),
                              aLocator->getPublicId(), aLocator->getLineNumber(),
                              aLocator->getColumnNumber());

    // Bail out if its fatal an we are to give up on the first fatal error
    if (errType == XMLErrorReporter::ErrType_Fatal && fExitOnFirstFatal)
        throw (XMLErrs::Codes) toEmit;
}