code: def _dispatch_validation_error(self, msg, writing=False):
          
          if writing:
              raise IOError(msg)
          else:
              warnings.warn(msg)
docs: Issue either a warning or an error depending on circumstance.
  
          If writing to file, then error out, as we do not wish to create bad
          JP2 files.  If reading, then we should be more lenient and just warn.