Skip to content

Commit b39e724

Browse files
jkbonfielddaviesrob
authored andcommitted
Report the reason for failing to open a reference.
We previously printed "failed to populate ref" etc, but not why. This would have been helpful in samtools/samtools#857 to diagnose the cause of the problem.
1 parent a13ac99 commit b39e724

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cram/open_trace_file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6868
#include <string.h>
6969
#include <unistd.h>
7070
#include <limits.h>
71+
#include <errno.h>
7172
#include <sys/types.h>
7273
#include <sys/stat.h>
7374
#include "cram/os.h"
@@ -78,6 +79,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7879
#include "cram/open_trace_file.h"
7980
#include "cram/misc.h"
8081
#include "htslib/hfile.h"
82+
#include "htslib/hts_log.h"
8183

8284
/*
8385
* Tokenises the search path splitting on colons (unix) or semicolons
@@ -183,8 +185,10 @@ mFILE *find_file_url(char *file, char *url) {
183185
}
184186
*cp++ = 0;
185187

186-
if (!(hf = hopen(buf, "r")))
188+
if (!(hf = hopen(buf, "r"))) {
189+
hts_log_error("Failed to open reference \"%s\": %s", buf, strerror(errno));
187190
return NULL;
191+
}
188192

189193
if (NULL == (mf = mfcreate(NULL, 0)))
190194
return NULL;

0 commit comments

Comments
 (0)