From: Braden M. <br...@us...> - 2007-07-11 22:18:19
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10648/src/libopenvrml/openvrml Modified Files: Tag: OpenVRML-0_16-BRANCH browser.cpp Log Message: Emit the message in an exception thrown from browser::get_resource to browser::err. Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.190.2.16 retrieving revision 1.190.2.17 diff -C2 -d -r1.190.2.16 -r1.190.2.17 *** browser.cpp 31 May 2007 07:18:17 -0000 1.190.2.16 --- browser.cpp 11 Jul 2007 22:18:16 -0000 1.190.2.17 *************** *** 5825,5828 **** --- 5825,5831 ---- * * @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> *************** *** 5841,5846 **** * 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 --- 5844,5854 ---- * 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 *************** *** 5951,5954 **** --- 5959,5965 ---- * @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 */ *************** *** 7233,7267 **** 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().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; } --- 7244,7287 ---- 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().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; } |