mksqlite  2.5
A MATLAB interface to SQLite
Exception handling with mksqlite
sqlite_exceptions
function sqlite_exceptions

    clear all
    close all
    clc
    dummy = mksqlite('version mex');
    fprintf( '\n\n' );

    commands = { ...
      'mksqlite(''open'',''filenotfound.db'', ''ro'');', ...  % opens non-existent file
      'mksqlite(''open'','''');', ...                         % open in-memory file
      'mksqlite(''select column_doesnt_exist'');', ...        % select a column that not exist
      'mksqlite(''syntax error'');', ...                      % Unknown statements
      'mksqlite( -10, ''open'', '''' );', ...                 % Illegal dbid
      'mksqlite( ''open'', '''' );', ...                      % MATLAB syntax error (not catched!)
    };

    for i = 1:numel( commands )
        if i == numel( commands )
            fprintf( '\nNext error will not be catched and thus terminates this script:' );
        end

        fprintf( '\nCalling %s\n', commands{i} );

        try
            eval( commands{i} );
            fprintf( 'succeeded\n' );

        % Exception handling
        catch ex

            % Get the error identifier
            switch ex.identifier
                case 'MKSQLITE:ANY'
                    % All errors from mksqlite
                    fprintf( 'mksqlite omitted an error: "%s"\n', ex.message );

                case 'SQLITE:ERROR'
                    % Explicit handler for SQLite syntax errors
                    fprintf( 'SQLite syntax error: "%s"\n', ex.message );

                otherwise
                    % Split "SQLITE:NAME" into its fields --> C={'SQLITE','NAME'}
                    C = regexp( ex.identifier, ':', 'split' );

                    if numel(C) == 2 && strcmpi( C{1}, 'SQLITE' )
                        % Handler for all remaining SQLite errors
                        switch( C{2} )
                            case {'AUTH', 'CANTOPEN' }
                                % Handle SQLITE:AUTH and SQLITE:CANTOPEN
                                fprintf( 'SQLite error while open database: "%s"\n', ex.message );

                            otherwise
                                % Any other SQLite error
                                fprintf( 'Any other SQLite error: "%s"\n', ex.message );
                        end
                    else
                        % Any other unknown exception, rethrow to outer scope
                        rethrow(ex);
                    end
            end

        end
    end
mksqlite Version 2.5 build: 133, ein MATLAB Interface zu SQLite
(c) 2008-2017 by Martin Kortmann <mail@kortmann.de>
                 Andreas Martin  <andimartin@users.sourceforge.net>
basierend auf SQLite Version 3.16.2 - http://www.sqlite.org
mksqlite verwendet:
 - DEELX perl kompatible regex engine Version 1.3 (Sswater@gmail.com)
 - BLOSC/LZ4 1.3.0-rc3.dev zur Datenkompression (Francesc Alted / Yann Collett) 
 - MD5 Message-Digest Algorithm (RFC 1321) Implementierung von Alexander Peslyak
   
Platform: PCWIN64, little endian




Calling mksqlite('open','filenotfound.db', 'ro');
SQLite error while open database: "unable to open database file"

Calling mksqlite('open','');
succeeded

Calling mksqlite('select column_doesnt_exist');
SQLite syntax error: "no such column: column_doesnt_exist"

Calling mksqlite('syntax error');
SQLite syntax error: "near "syntax": syntax error"

Calling mksqlite( -10, 'open', '' );
mksqlite omitted an error: "ungueltiger Datenbankhandle"

Next error will not be catched and thus terminates this script:
Calling mksqlite( 'open', '' );
succeeded