Mercurial > forge
changeset 12449:4e2f17cc8e70 octave-forge
Tamed down some error messages (avoid traceback)
author | prnienhuis |
---|---|
date | Sat, 26 Apr 2014 12:09:36 +0000 |
parents | 2aa3905997ec |
children | a129863f71e4 |
files | main/io/inst/chk_spreadsheet_support.m main/io/inst/getxmlnode.m main/io/inst/odsclose.m main/io/inst/odsopen.m main/io/inst/odsread.m main/io/inst/odswrite.m main/io/inst/rfsearch.m main/io/inst/xlsclose.m main/io/inst/xlsfinfo.m main/io/inst/xlsopen.m main/io/inst/xlsread.m main/io/inst/xlswrite.m |
diffstat | 12 files changed, 59 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/main/io/inst/chk_spreadsheet_support.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/chk_spreadsheet_support.m Sat Apr 26 12:09:36 2014 +0000 @@ -172,6 +172,7 @@ ## 2014-04-14 Updated texinfo header & OCT r/w support messages ## 2014-04-15 More updates to texinfo header ## 2014-04-26 Check for built-in Java support before trying to handle Java stuff +## '' Cleaned up various messages function [ retval, sinterfaces, loaded_jars ] = chk_spreadsheet_support (path_to_jars, dbug, path_to_ooo) @@ -219,6 +220,11 @@ interfaces = {"COM", "POI", "POI+OOXML", "JXL", "OXS", "OTK", "JOD", "UNO", "OCT"}; ## Order = vital + + ## Just mention OCT interface + if(dbug) + printf ("(OCT interface... OK, included in io package)\n\n"); + endif ## Check if MS-Excel COM ActiveX server runs. Only needed on Windows systems if (ispc) @@ -259,19 +265,22 @@ ## Check Java if (dbug > 1) - printf (" 1. Checking Octave's Java support... "); + printf ("1. Checking Octave's Java support... "); endif if (! octave_config_info.features.JAVA) ## Nothing to do here anymore if (abs (dbug) >=1) printf ("none.\nThis Octave has no built-in Java support. Skipping Java checks\n"); + if (! retval) + printf ("Only ODS 1.2 (.ods) & OOXML (.xlsx) r/w support & .gnumeric read support present\n"); + endif endif return elseif (dbug > 1) printf ("OK.\n"); endif - if (dbug) + if (dbug > 1) printf ("2. Checking Java dependencies...\n"); endif if (dbug > 1) @@ -315,21 +324,18 @@ if (jmem < 400) printf ("should better be at least 400 MB!\n"); printf (' Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n'); - printf (" %s\n", [matlabroot filesep "share" filesep "octave" filesep "packages" filesep "java-<version>" filesep "java.opts"]); + printf (" %s\n", [matlabroot filesep "share" filesep "octave" filesep "packages" filesep "java-<version>" filesep "java.opts\n"]); else printf ("sufficient.\n"); endif endif - if (dbug) - printf ("Java support OK\n"); - endif endif catch ## No Java support end_try_catch if (! tmp1) ## We can return as for below code Java is required. - if (dbug) + if (dbug > 1) printf ("No Java support found.\n"); if (! retval) printf ("Only ODS 1.2 (.ods) & OOXML (.xlsx) r/w support & .gnumeric read support present\n"); @@ -339,7 +345,7 @@ endif if (dbug) - printf ("\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n"); + printf ("Checking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n"); endif ## Try Java & Apache POI. First Check basic .xls (BIFF8) support @@ -425,7 +431,7 @@ endif catch ## Wrong OpenXLS.jar version (probably <= 6.08). V. 10 is required now - warning ("OpenXLS.jar version is outdated; please upgrade to v.10"); + warning ("OpenXLS.jar version is outdated; please upgrade to v.10\n"); end_try_catch endif
--- a/main/io/inst/getxmlnode.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/getxmlnode.m Sat Apr 26 12:09:36 2014 +0000 @@ -37,6 +37,7 @@ ## 2013-10-20 Fix typos in input validation error messages ## '' Better input validation ## 2013-11-04 More robust <single node/> detection +## 2014-04-26 Fix error messages (no more traceback) function [ node, spos, epos ] = getxmlnode (xml, tag, is=1, contnt=0) @@ -49,11 +50,11 @@ ## Input validation if (! ischar (xml) || ! ischar (tag)) - error ("getxmlnode: text strings expected for first two args"); + error ("getxmlnode: text strings expected for first two args\n"); elseif (nargin==3 && (! islogical (is) && ! isnumeric (is))) - error ("getxmlnode: logical or numerical value expected for arg #3"); + error ("getxmlnode: logical or numerical value expected for arg #3\n"); elseif (nargin==4 && (! islogical (contnt) && ! isnumeric (contnt))) - error ("getxmlnode: logical or numerical value expected for arg #3"); + error ("getxmlnode: logical or numerical value expected for arg #3\n"); endif is = max (is, 1);
--- a/main/io/inst/odsclose.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/odsclose.m Sat Apr 26 12:09:36 2014 +0000 @@ -75,18 +75,19 @@ ## 2013-10-02 Texinfo header adapted ## 2013-12-01 Style fixes ## 2014-04-13 Updated copyright strings +## 2014-04-26 Fix error messages (no more traceback) function [ ods ] = odsclose (ods, varargs) ## If needed warn that dangling spreadsheet pointers may be left if (nargout < 1) - warning ("odsclose.m: return argument missing - ods invocation not reset."); + warning ("odsclose.m: return argument missing - ods invocation not reset.\n"); endif force = 0; if (isempty (ods)) - warning ("odsclose: file pointer struct is empty; was it already closed?")'; + warning ("odsclose: file pointer struct is empty; was it already closed?\n")'; return endif @@ -99,11 +100,11 @@ elseif (! isempty (strfind (tolower (varargin{ii}), "."))) ## Apparently a file name. First some checks.... if (ods.changed == 0 || ods.changed > 2) - warning ("odsclose.m: file %s wasn't changed, new filename ignored.", ods.filename); + warning ("odsclose.m: file %s wasn't changed, new filename ignored.\n", ods.filename); elseif (! strcmp (xls.xtype, "UNO") && ... isempty (strfind ( lower (filename), ".ods"))) ## UNO will write any file type, all other interfaces only .ods - error ("odsclose.m: .ods suffix lacking in filename %s", filename); + error ("odsclose.m: .ods suffix lacking in filename %s\n", filename); else ## Preprocessing / -checking ready. ## Assign filename arg to file ptr struct @@ -132,13 +133,13 @@ ##elseif ---- < Other interfaces here > else - error (sprintf ("ods2close: unknown OpenOffice.org .ods interface - %s.",... + error (sprintf ("ods2close: unknown OpenOffice.org .ods interface - %s.\n",... ods.xtype)); endif if (ods.changed && ods.changed < 3) - error (sprintf ("odsclose.m: could not save file %s - read-only or in use elsewhere?",... + error (sprintf ("odsclose.m: could not save file %s - read-only or in use elsewhere?\n",... ods.filename)); if (force) ods = [];
--- a/main/io/inst/odsopen.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/odsopen.m Sat Apr 26 12:09:36 2014 +0000 @@ -138,6 +138,7 @@ ## 2014-01-23 OCT ods write support for .ods ## 2014-04-14 Update texinfo header ## 2014-04-15 More updates to texinfo header +## 2014-04-26 Fix error messages (no more traceback) function [ ods ] = odsopen (filename, rw=0, reqinterface=[]) @@ -215,7 +216,7 @@ ## .ods write support is supported if (odsintf_cnt == 1 && odsinterfaces.OCT && ! strcmpi (ext, ".ods")) ## Check if OCT is only interface and writing is requested - error ("OCT interface doesn't support writing gnumeric files (yet)"); + error ("odsopen: OCT interface has no support for writing gnumeric files (yet)\n"); endif rw = 1; endif @@ -293,7 +294,7 @@ if (odsinterfaces.UNO && ! odssupport && ftype < 5) ## Warn for LO / OOo stubbornness if (ftype == 0 || ftype == 5 || ftype == 6) - warning ("UNO interface will write ODS format for unsupported file extensions") + warning ("UNO interface will write ODS format for unsupported file extensions\n") endif [ ods, odssupport, lastintf ] = ... __UNO_spsh_open__ (ods, rw, filename, odssupport); @@ -311,7 +312,7 @@ if (! odssupport) ## Below message follows after getodsinterfaces printf ("None.\n"); - warning ("odsopen.m: no support for OpenOffice.org .ods I/O"); + warning ("odsopen.m: no support for OpenOffice.org .ods I/O\n"); ods = []; chkintf = []; else
--- a/main/io/inst/odsread.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/odsread.m Sat Apr 26 12:09:36 2014 +0000 @@ -142,11 +142,12 @@ ## 2013-12-01 Updated texinfo header ## 2014-04-13 Updated copyright strings and texinfo header ## 2014-04-15 More updates to texinfo header +## 2014-04-26 Fix error messages (no more traceback) function [ numarr, txtarr, rawarr, lim ] = odsread (filename, wsh=1, datrange=[], reqintf=[]) if (! ischar (filename)) - error ("filename (text string) expected for argument #1, not a %s", class (filename)); + error ("odsread: filename (text string) expected for argument #1, not a %s\n", class (filename)); endif if (nargin < 1 || ! (strcmpi (".ods", filename(end-3:end)) || ... strcmpi (".sxc", filename(end-3:end)) || ... @@ -163,7 +164,7 @@ if (rstatus) [numarr, txtarr, lim] = parsecell (rawarr, ods.limits); else - warning (sprintf ("No data read from %s.", filename)); + warning (sprintf ("No data read from %s.\n", filename)); numarr = []; endif
--- a/main/io/inst/odswrite.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/odswrite.m Sat Apr 26 12:09:36 2014 +0000 @@ -100,6 +100,7 @@ ## 2013-12-18 Copyright string updates, style fixes ## 2014-01-01 Drop file extension check ## 2014-04-13 Updated copyright strings & texinfo header +## 2014-04-26 Fix error messages (no more traceback) function [ rstatus ] = odswrite (filename, data, wsh=1, crange="", reqintf=[]) @@ -116,7 +117,7 @@ ## If rstatus was not OK, reset change indicator in ods pointer if (! rstatus) ods.changed = rstatus; - warning ("odswrite: data transfer errors, file not rewritten"); + warning ("odswrite: data transfer errors, file not rewritten\n"); endif ods = odsclose (ods);
--- a/main/io/inst/rfsearch.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/rfsearch.m Sat Apr 26 12:09:36 2014 +0000 @@ -60,6 +60,7 @@ ## '' Name changed to rfseach ## 2013-12-14 Texinfo header adaptations (recursion noted) ## 2014-01-03 Check for empty subdir before exploring it (L.95) +## 2014-04-26 Fix error messages (no more traceback) function [ fpath ] = rfsearch (dname, fname, mxdpth=1, depth=0) @@ -67,9 +68,9 @@ if (nargin < 2) print_usage () elseif ((! ischar (dname)) || (! ischar (fname))) - error ("rsearchfile: character arguments expected for DNAME and FNAME"); + error ("rsearchfile: character arguments expected for DNAME and FNAME\n"); elseif (! isnumeric (mxdpth)) - error ("Numeric value >= 0 expected for MAXDEPTH"); + error ("Numeric value >= 0 expected for MAXDEPTH\n"); elseif (mxdpth < 0) warning ("rsearchfile: negative value for MAXDEPTH (%d) set to 0\n", mxdpth); mxdpth = 0;
--- a/main/io/inst/xlsclose.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/xlsclose.m Sat Apr 26 12:09:36 2014 +0000 @@ -83,11 +83,12 @@ ## 2013-12-29 Style fixes ## 2014-01-01 Style fixes ## 2014-04-13 Updated copyright strings +## 2014-04-26 Fix error messages (no more traceback) function [ xls ] = xlsclose (xls, varargs) if (isempty (xls)) - warning ("xlsclose: file pointer struct was already closed"); + warning ("xlsclose: file pointer struct was already closed\n"); return endif @@ -103,13 +104,13 @@ elseif (! isempty (strfind (tolower (varargin{ii}), "."))) ## Apparently a file name. First some checks.... if (xls.changed == 0 || xls.changed > 2) - warning ("xlsclose: file %s wasn't changed, new filename ignored.", xls.filename); + warning ("xlsclose: file %s wasn't changed, new filename ignored.\n", xls.filename); elseif (strcmp (xls.xtype, "JXL")) - error ("xlsclose: JXL doesn't support changing filename, new filename ignored."); + error ("xlsclose: JXL doesn't support changing filename, new filename ignored.\n"); elseif (! ((strcmp (xls.xtype, "COM") || strcmp (xls.xtype, "UNO")) ... && isempty (strfind ( lower (filename), ".xls")))) # Excel/ActiveX && OOo (UNO bridge) will write any valid filetype; POI/JXL/OXS need .xls[x] - error ("xlsclose: .xls or .xlsx suffix lacking in filename %s", filename); + error ("xlsclose: .xls or .xlsx suffix lacking in filename %s\n", filename); else ## For multi-user environments, uncomment below AND relevant stanza in xlsopen ## In case of COM, be sure to first close the open workbook @@ -148,7 +149,7 @@ endif if (xls.changed && xls.changed < 3) - warning (sprintf ("xlsclose: file %s could not be saved. Read-only or in use elsewhere?", ... + warning (sprintf ("xlsclose: file %s could not be saved. Read-only or in use elsewhere?\n", ... xls.filename)); if (force) xls = [];
--- a/main/io/inst/xlsfinfo.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/xlsfinfo.m Sat Apr 26 12:09:36 2014 +0000 @@ -94,7 +94,7 @@ ## 2013-12-01 Style fixes & support for more file types than just Excel ## 2013-12-29 Style fixes ## 2014-04-15 Updates to texinfo header - +## 2014-04-26 Fix error messages (no more traceback) function [ filetype, sh_names, fformat ] = xlsfinfo (filename, reqintf=[]) @@ -143,7 +143,7 @@ ##elseif <Other Excel interfaces below> else - error (sprintf ("xlsfinfo: unknown Excel .xls interface - %s.", xls.xtype)); + error (sprintf ("xlsfinfo: unknown Excel .xls interface - %s.\n", xls.xtype)); endif
--- a/main/io/inst/xlsopen.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/xlsopen.m Sat Apr 26 12:09:36 2014 +0000 @@ -139,7 +139,8 @@ ## '' Add warning that UNO will write ODS f. unsupported file extensions ## '' Copyright string update ## 2014-02-02 Allow write support for OCT interface -## 2014-04-13 Updated texinfo header +## 2014-04-13 Updated texinfo header +## 2014-04-26 Fix error messages (no more traceback) function [ xls ] = xlsopen (filename, xwrite=0, reqinterface=[]) @@ -258,7 +259,7 @@ if (xwrite) ## Catch attempts to write gnumeric if (ftype == 5) - error ("There's only read support for gnumeric files"); + error ("xlsopen: there's only read support for gnumeric files\n"); endif fmode = 'r+b'; if (! has_suffix) @@ -337,7 +338,7 @@ if ((! xlssupport) && xlsinterfaces.UNO && (ftype != 5)) ## Warn for LO / OOo stubbornness if (ftype == 0 || ftype == 5 || ftype == 6) - warning ("UNO interface will write ODS format for unsupported file extensions") + warning ("UNO interface will write ODS format for unsupported file extensions\n") endif [ xls, xlssupport, lastintf ] = __UNO_spsh_open__ (xls, xwrite, filename, xlssupport); endif @@ -359,11 +360,11 @@ if (ftype != 6) ## This message is appended after message from getxlsinterfaces() printf ("None.\n"); - warning ("xlsopen.m: no support for spreadsheet I/O"); + warning ("xlsopen.m: no support for spreadsheet I/O\n"); endif else ## No match between filte type & interface found - warning ("xlsopen.m: file type not supported by %s %s %s %s %s %s", reqinterface{:}); + warning ("xlsopen.m: file type not supported by %s %s %s %s %s %s\n", reqinterface{:}); endif xls = []; ## Reset found interfaces for re-testing in the next call. Add interfaces if needed.
--- a/main/io/inst/xlsread.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/xlsread.m Sat Apr 26 12:09:36 2014 +0000 @@ -157,18 +157,19 @@ ## 2013-12-20 Style fixes ## 2013-12-27 In case of .csv fall back to csvread for lazy Matlab users ## 2014-04-13 Updated copyright strings & texinfo header -## 2014-04-15 More updates to texinfo header +## 2014-04-15 More updates to texinfo header +## 2014-04-26 Fixed error messages (no traceback) function [ numarr, txtarr, rawarr, lims ] = xlsread (fn, wsh, datrange, reqintf=[]) rstatus = 0; if (nargin < 1) - error ("xlsread: no input arguments specified") + error ("xlsread: no input arguments specified\n") numarr = []; txtarr={}; rawarr = {}; return elseif (! ischar (fn)) - error ("filename (text string) expected for argument #1, not a %s", class (fn)); + error ("filename (text string) expected for argument #1, not a %s\n", class (fn)); elseif (nargin == 1) wsh = 1; datrange = "";
--- a/main/io/inst/xlswrite.m Sat Apr 26 10:39:42 2014 +0000 +++ b/main/io/inst/xlswrite.m Sat Apr 26 12:09:36 2014 +0000 @@ -116,7 +116,8 @@ ## 2013-12-07 Updated copyright string ## '' Check on empty file ptr struct after calling xlsopen ## 2014-03-18 Convey full crange to oct2xls, not just topleft -## 2014-04-13 Update texinfo header +## 2014-04-13 Update texinfo header +## 2014-04-26 Fixed error message (no traceback) function [ rstatus ] = xlswrite (filename, arr, arg3, arg4, arg5) @@ -126,7 +127,7 @@ if (nargin < 2) usage ("Insufficient arguments - see 'help xlswrite'"); elseif (! ischar (filename)) - error ("First argument must be a filename (incl. suffix)"); + error ("xlswrite: first argument must be a filename (incl. suffix)\n"); elseif (nargin == 2) ## Assume first worksheet and full worksheet starting at A1 wsh = 1;