From: Braden M. <br...@us...> - 2007-07-11 22:18:46
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10709/src/libopenvrml/openvrml Modified Files: browser.cpp Log Message: Emit the message in an exception thrown from resource_fetcher::get_resource to browser::err. Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.220 retrieving revision 1.221 diff -C2 -d -r1.220 -r1.221 *** browser.cpp 1 Jun 2007 06:33:59 -0000 1.220 --- browser.cpp 11 Jul 2007 22:18:44 -0000 1.221 *************** *** 4646,4649 **** --- 4646,4652 ---- * * @return the requested resource as a stream. + * + * @exception std::invalid_argument if @p uri is malformed or in an + * unsupported format. */ std::auto_ptr<openvrml::resource_istream> *************** *** 4662,4667 **** * of this function for all of its input needs. As such, what kind of * resources OpenVRML is capable of resolving is entirely dependent on code ! * provided by the application. A trivial implementation designed to handle ! * only @c file resources can use @c std::filebuf: * * @code --- 4665,4675 ---- * of this function for all of its input needs. As such, what kind of * resources OpenVRML is capable of resolving is entirely dependent on code ! * provided by the application. ! * ! * Implementations should throw @c std::invalid_argument if @p uri is ! * malformed or in an format that is not supported by the implementation. ! * ! * A trivial implementation designed to handle only @c file resources can use ! * @c std::filebuf: * * @code *************** *** 4772,4775 **** --- 4780,4786 ---- * @return the requested resource as a stream. * + * @exception std::invalid_argument if @p uri is malformed or in an + * unsupported format. + * * @sa ftp://ftp.rfc-editor.org/in-notes/std/std66.txt */ *************** *** 7488,7522 **** for (vector<string>::size_type i = 0; i < url.size(); ++i) { ! try { ! // ! // Throw invalid_url if it isn't a valid URI. ! // ! uri test_uri(url[i]); // ! // If we have a relative reference, resolve it against this->url(); ! // unless the parent is null and this->url() is empty, in which ! // case we are loading the root scene. In that case, construct an ! // absolute file URL. // ! const uri absolute_uri = !relative(test_uri) ! ? test_uri ! : (!this->parent() && this->url().empty()) ! ? create_file_url(test_uri) ! : test_uri ! .resolve_against(uri(this->url())); ! try { ! in = this->browser().fetcher_.get_resource(absolute_uri); ! } catch (...) { ! throw unreachable_url(); ! } ! if (!in.get() || !(*in)) { throw unreachable_url(); } ! break; ! } catch (bad_url & ex) { ! this->browser().err(ex.what()); continue; } } ! if (!in.get()) { throw no_alternative_url(); } return in; } --- 7499,7542 ---- for (vector<string>::size_type i = 0; i < url.size(); ++i) { ! // ! // Throw invalid_url if it isn't a valid URI. ! // ! uri test_uri(url[i]); + // + // If we have a relative reference, resolve it against this->url(); + // unless the parent is null and this->url() is empty, in which case + // we are loading the root scene. In that case, construct an absolute + // file URL. + // + const uri absolute_uri = !relative(test_uri) + ? test_uri + : (!this->parent() && this->url().empty()) + ? create_file_url(test_uri) + : test_uri + .resolve_against(uri(this->url())); + try { + in = this->browser().fetcher_.get_resource(absolute_uri); + } catch (std::exception & ex) { + std::ostringstream msg; + msg << string(absolute_uri) << ": " << ex.what(); + this->browser().err(msg.str()); + continue; + } catch (...) { // ! // Swallow unrecognized exceptions. Output to browser::err ! // happens below when "in" is found to be unusable. // ! } ! if (!in.get() || !(*in)) { ! std::ostringstream msg; ! msg << string(absolute_uri) ! << ": unrecognized error during resolution"; ! this->browser().err(msg.str()); continue; } + break; // Success. } ! if (!in.get() || !(*in)) { throw no_alternative_url(); } return in; } |