From 3a1adeaa25a4e34087b03fd35dcf44f97941feff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 16 Jul 2019 14:25:30 +0300 Subject: [PATCH] Use errno Former-commit-id: b1a8d1a27501cbd6fe57f42c5efa630862b60748 --- qpms/qpms_c.pyx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index 96974ca..af0b511 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -14,7 +14,7 @@ cimport cython from cython.parallel cimport parallel, prange import enum import warnings - +import os # Here will be enum and dtype definitions; maybe move these to a separate file class VSWFType(enum.IntEnum): @@ -1138,10 +1138,11 @@ cdef class TMatrixInterpolator: qpms_load_scuff_tmatrix_crash_on_failure = False self.spec = bspec cdef char * cpath = make_c_string(filename) - if QPMS_SUCCESS != qpms_load_scuff_tmatrix(cpath, self.spec.rawpointer(), + retval = qpms_load_scuff_tmatrix(cpath, self.spec.rawpointer(), &(self.nfreqs), &(self.freqs), &(self.freqs_su), - &(self.tmatrices_array), &(self.tmdata)): - raise IOError("Could not read T-matrix from %s" % filename) + &(self.tmatrices_array), &(self.tmdata)) + if (retval != QPMS_SUCCESS): + raise IOError("Could not read T-matrix from %s: %s" % (filename, os.strerror(retval))) if 'symmetrise' in kwargs: sym = kwargs['symmetrise'] if isinstance(sym, FinitePointGroup):