Changeset dc8a553 in sasview


Ignore:
Timestamp:
Aug 9, 2016 6:41:15 AM (5 years ago)
Author:
lewis
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
0e11ec7
Parents:
9c500ab
Message:

Show error message when binary file can't be loaded

Location:
src/sas/sascalc/file_converter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/file_converter/bsl_loader.py

    r9c500ab rdc8a553  
    3131        sasdata_filename = filename.replace('000.', '001.') 
    3232        if sasdata_filename == filename: 
    33             err_msg = ("Invalid header filename {}.\n Should be of the format " 
     33            err_msg = ("Invalid header filename {}.\nShould be of the format " 
    3434                "Xnn000.XXX where X is any alphanumeric character and n is any" 
    3535                " digit.").format(filename) 
  • src/sas/sascalc/file_converter/c_ext/bsl_loader.c

    re070dc0 rdc8a553  
    170170    input_file = fopen(self->params.filename, "rb"); 
    171171    if (!input_file) { 
     172        // BSL filenames are 10 characters long 
     173        // Filename validity checked in bsl_loader.py 
     174        size_t filename_start = strlen(self->params.filename) - 10; 
     175        char *filename = self->params.filename + filename_start; 
     176        char *err_msg = (char *)malloc(sizeof(char) * 32); 
     177 
     178        sprintf(err_msg, "Unable to open file: %s", filename); 
     179 
     180        PyErr_SetString(PyExc_RuntimeError, err_msg); 
     181        free(err_msg); 
    172182        return NULL; 
    173183    } 
Note: See TracChangeset for help on using the changeset viewer.