void ShaderEditASM::FormatCompileErrorLocation(const string &programSource, GLint errorPos, string &retLog) { //Get the number of lines uint lineNum = 1; uint charNum = 1; for(GLint i=0; i<errorPos && i<(int)programSource.size(); i++) { //Count the number of new lines if(programSource[i] == '\n') { lineNum++; charNum = 1; } else { charNum++; } } //Copy five characters near the error string errorData(programSource,errorPos,5); //Append the error string data string buffer; StringPrintF(buffer,"line %u, column %u: Compile error near >%s< char (%d)\n", lineNum, charNum, errorData.c_str(), errorPos); retLog += buffer; }
void FrameLoaderClientBlackBerry::dispatchDidFailProvisionalLoad(const ResourceError& error) { if (isMainFrame()) { m_loadError = error; m_webPagePrivate->setLoadState(WebPagePrivate::Failed); if (error.domain() == ResourceError::platformErrorDomain && (error.errorCode() == BlackBerry::Platform::FilterStream::StatusErrorAlreadyHandled)) { // Error has already been displayed by client. return; } if (error.domain().isEmpty() && !error.errorCode() && error.failingURL().isEmpty() && error.localizedDescription().isEmpty()) { // Don't try to display empty errors returned from the unimplemented error functions in FrameLoaderClientBlackBerry - there's nothing to display anyway. return; } } if (m_webPagePrivate->m_dumpRenderTree) m_webPagePrivate->m_dumpRenderTree->didFailProvisionalLoadForFrame(m_frame); if (!isMainFrame()) return; String errorPage = m_webPagePrivate->m_client->getErrorPage(error.errorCode() , error.localizedDescription().isEmpty() ? "" : error.localizedDescription().utf8().data() , error.failingURL().isEmpty() ? "" : error.failingURL().utf8().data()); // Make sure we're still in the provisionalLoad state - getErrorPage runs a // nested event loop while it's waiting for client resources to load so // there's a small window for the user to hit stop. if (m_frame->loader()->provisionalDocumentLoader()) { SubstituteData errorData(utf8Buffer(errorPage), "text/html", "utf-8", KURL(KURL(), error.failingURL())); ResourceRequest originalRequest = m_frame->loader()->provisionalDocumentLoader()->originalRequest(); // Loading using SubstituteData will replace the original request with our // error data. This must be done within dispatchDidFailProvisionalLoad, // and do NOT call stopAllLoaders first, because the loader checks the // provisionalDocumentLoader to decide the load type; if called any other // way, the error page is added to the end of the history instead of // replacing the failed load. // // If this comes from a back/forward navigation, we need to save the current viewstate // to original historyitem, and prevent the restore of view state to the error page. if (isBackForwardLoadType(m_frame->loader()->loadType())) { m_frame->loader()->history()->saveScrollPositionAndViewStateToItem(m_frame->loader()->history()->currentItem()); ASSERT(m_frame->loader()->history()->provisionalItem()); m_frame->loader()->history()->provisionalItem()->viewState().shouldSaveViewState = false; } m_loadingErrorPage = true; m_frame->loader()->load(originalRequest, errorData, false); } }
XMLTree::XMLTree(bool validate, const char *docBuffer, std::size_t bufferLen) : docPtr(NULL) { if (static_cast<const char *> (NULL) == docBuffer) { throw std::invalid_argument("XMLTree(docBuffer) is NULL"); } if (0 == bufferLen) { bufferLen = std::strlen(docBuffer); if (0 == bufferLen) { throw std::invalid_argument("XMLTree(docBuffer) is empty"); } } if (INT_MAX < bufferLen) { throw std::invalid_argument("XMLTree(docBuffer) too long"); } docPtr = xmlReadMemory(docBuffer, static_cast<int> (bufferLen), NULL, NULL, XML_PARSE_NONET); if (static_cast<xmlDocPtr> (NULL) == docPtr) { throw ParseException("XMLTree() unable to parse docBuffer"); } if (validate) { // // Now, try to validate the document. // XMLErrorData errorData("XMLTree() "); xmlValidCtxt cvp; cvp.userData = &errorData; cvp.error = reinterpret_cast<xmlValidityErrorFunc> (XMLErrorHandler); cvp.warning = reinterpret_cast<xmlValidityErrorFunc> (XMLErrorHandler); if (!xmlValidateDocument(&cvp, docPtr)) { xmlFreeDoc(docPtr); if (errorData.errorDetected) { throw ParseException(errorData.message); } else { throw ParseException("XMLTree() docBuffer does not validate"); } } } if (static_cast<xmlNodePtr> (NULL) == xmlDocGetRootElement(docPtr)) { xmlFreeDoc(docPtr); throw ParseException("XMLTree() empty document"); } }
bool QJsonRpcMessage::operator==(const QJsonRpcMessage &message) const { if (message.d == d) return true; if (message.type() == type()) { if (message.type() == QJsonRpcMessage::Error) { return (message.errorCode() == errorCode() && message.errorMessage() == errorMessage() && message.errorData() == errorData()); } else { if (message.type() == QJsonRpcMessage::Notification) { return (message.method() == method() && message.params() == params()); } else { return (message.id() == id() && message.method() == method() && message.params() == params()); } } } return false; }