@@ -1932,6 +1932,8 @@ static int cram_populate_ref(cram_fd *fd, int id, ref_entry *r) {
19321932 hts_log_info ("Querying ref %s" , m5_str );
19331933
19341934 if (!(ref_fn = m5_to_path (m5_str ))){
1935+ hts_log_warning ("Failed to find reference with MD5 \"%s\"." , m5_str );
1936+
19351937 no_m5 = 1 ;
19361938 }
19371939 }
@@ -1954,8 +1956,11 @@ static int cram_populate_ref(cram_fd *fd, int id, ref_entry *r) {
19541956 return -1 ;
19551957 fd -> refs -> fp = NULL ;
19561958 }
1957- if (!(refs = refs_load_fai (fd -> refs , fn , 0 )))
1959+ if (!(refs = refs_load_fai (fd -> refs , fn , 0 ))){
1960+ hts_log_warning ("Failed to find reference \"%s\" from the @SQ UR: tag." , fn );
1961+
19581962 return -1 ;
1963+ }
19591964 sanitise_SQ_lines (fd );
19601965
19611966 fd -> refs = refs ;
@@ -1984,7 +1989,12 @@ static int cram_populate_ref(cram_fd *fd, int id, ref_entry *r) {
19841989 /* Read the whole sequence into memory, as we're dealing with a remote file */
19851990 kstring_t ref_seq = {0 };
19861991
1987- hFILE * ref_hfile = hopen (ref_fn , "r" );
1992+ hFILE * ref_hfile ;
1993+ if (!(ref_hfile = hopen (ref_fn , "r" ))){
1994+ hts_log_error ("Failed to open reference \"%s\": %s" , ref_fn , strerror (errno ));
1995+
1996+ return -1 ;
1997+ }
19881998
19891999 do {
19902000 ks_resize (& ref_seq , ks_len (& ref_seq ) + READ_LENGTH );
@@ -2022,7 +2032,6 @@ static int cram_populate_ref(cram_fd *fd, int id, ref_entry *r) {
20222032 free (ref_fn );
20232033
20242034 return 0 ;
2025-
20262035}
20272036
20282037static void cram_ref_incr_locked (refs_t * r , int id ) {
0 commit comments