Changeset 3166


Ignore:
Timestamp:
Jan 17, 2014, 3:23:05 AM (9 years ago)
Author:
Peter
Message:

throw OutBamFile::error when OutBamFile::write fails. closes #778

Location:
trunk/yat/omic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/omic/BamFile.cc

    r3162 r3166  
    163163  {
    164164    if (samwrite(sf_, read.bam_)<=0) {
    165       // FIXME if wanted perhaps we should throw an OutBamFile::error
    166       // instead that can hold \a read
    167       throw utility::runtime_error("OutBamFile::write failed");
     165      throw OutBamFile::error(read);
    168166    }
    169167  }
    170168
     169
     170  // OutBamFile::error
     171
     172  OutBamFile::error::error(const BamRead& r)
     173    : IO_error(""), read_(r) {}
     174
     175
     176  OutBamFile::error::~error(void) throw() {}
     177
     178
     179  const BamRead& OutBamFile::error::read(void) const
     180  { return read_; }
     181
    171182}}}
  • trunk/yat/omic/BamFile.h

    r3160 r3166  
    235235       \brief write a read to output file
    236236
    237        \throw utility::runtime_error if write failed
     237       \throw OutBamFile::error if write failed
     238
     239       \since yat 0.12
    238240     */
    239241    void write(const BamRead& read);
     242
     243    /**
     244       \brief Error thrown from OutBamFile::write(const BamRead&) at failure
     245     */
     246    class error : public utility::IO_error
     247    {
     248    public:
     249      /// \brief Constructor
     250      error(const BamRead&);
     251      /// \brief Destructor
     252      // has to be throw() since base class destructor is
     253      virtual ~error(void) throw();
     254      /**
     255         \return bam read that failed
     256       */
     257      const BamRead& read(void) const;
     258    private:
     259      BamRead read_;
     260    }; // end of class error
     261
    240262  private:
    241263  };
Note: See TracChangeset for help on using the changeset viewer.