Changeset 1628 for trunk/yat


Ignore:
Timestamp:
Nov 17, 2008, 10:24:18 PM (12 years ago)
Author:
Peter
Message:

improving exception message

Location:
trunk/yat/utility
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/FileUtil.cc

    r1627 r1628  
    9898    if ( failed && (errno!=ENOENT) ) {
    9999      std::stringstream ss;
    100       ss << "stat(2) call failed with errno: " << errno;
     100      ss << "stat(2) call failed with errno: " << errno << "\n"
     101         << strerror(errno);
    101102      throw IO_error(ss.str());
    102103    }
  • trunk/yat/utility/OptionFile.cc

    r1487 r1628  
    4848      return;
    4949    FileUtil fu(value().c_str());
    50     if (exist_ && !fu.exists()){
     50    bool exists=false;
     51    try {
     52      exists = fu.exists();
     53    }
     54    catch (IO_error& e) {
     55      std::stringstream ss;
     56      ss << "cannot stat `" << value() << "': " << strerror(errno);
     57      errno = 0;
     58      throw cmd_error(ss.str());
     59    }
     60    if (exist_ && !exists){
    5161      std::stringstream ss;
    5262      ss << "cannot stat `" << value() << "': No such file or directory";
     
    5868        if (*iter=='r' && fu.permissions("r")){
    5969          std::stringstream ss;
    60           ss << "cannot stat `" << value() << "': No such file or directory";
     70          ss << "cannot open `" << value() << "' for reading: Permission denied";
    6171          throw cmd_error(ss.str());
    6272        }
Note: See TracChangeset for help on using the changeset viewer.