;this file contains definitions for return status and error handling. ; (sc-include-once sph-status "foreign/sph/status") (enum (dg-status-id-undefined dg-status-id-input-type dg-status-id-max-id dg-status-id-data-length dg-status-id-not-implemented dg-status-id-duplicate dg-status-id-memory dg-status-id-condition-unfulfilled dg-status-id-missing-argument-dg-root dg-status-id-path-not-accessible-dg-root dg-status-id-no-more-data dg-status-group-dg dg-status-group-lmdb dg-status-group-libc)) (define (dg-status-group-id->name a) (b8* status-i-t) (return (case* = a (dg-status-group-dg "sph-dg") (dg-status-group-lmdb "lmdb") (dg-status-group-libc "libc") (else "")))) (define (dg-status-description a) (b8* status-t) (return (case* = a.group (dg-status-group-dg (convert-type (case* = a.id (dg-status-id-input-type "input argument is of wrong type") (dg-status-id-data-length "intern data too large") (dg-status-id-duplicate "element already exists") (dg-status-id-not-implemented "not implemented") (dg-status-id-missing-argument-dg-root "missing argument 'dg-root'") (dg-status-id-path-not-accessible-dg-root "root not accessible") (dg-status-id-memory "not enough memory or other memory allocation error") (dg-status-id-max-id "maximum identifier value has been reached") (dg-status-id-condition-unfulfilled "condition unfulfilled") (dg-status-id-no-more-data "no more data to read") (else "")) b8*)) (dg-status-group-lmdb (convert-type (mdb-strerror a.id) b8*)) (else (convert-type "" b8*))))) (define (dg-status-name a) (b8* status-t) (return (case* = a.group (dg-status-group-dg (convert-type (case* = a.id (dg-status-id-input-type "input-type") (dg-status-id-data-length "data-length") (dg-status-id-duplicate "duplicate") (dg-status-id-not-implemented "not-implemented") (dg-status-id-missing-argument-dg-root "missing-argument-dg-root") (dg-status-id-path-not-accessible-dg-root "path-not-accessible-dg-root") (dg-status-id-memory "memory") (dg-status-id-max-id "max-id-reached") (dg-status-id-condition-unfulfilled "condition-unfulfilled") (dg-status-id-no-more-data "no-more-data") (else "unknown")) b8*)) (dg-status-group-lmdb (convert-type (mdb-strerror a.id) b8*)) (else (convert-type "unknown" b8*))))) (pre-define (dg-status-set-id-goto status-id) (status-set-both-goto dg-status-group-dg status-id)) (pre-define (dg-status-require-read! expression) (set status expression) (if (not (or status-success? (status-id-is? dg-status-id-no-more-data))) status-goto)) (pre-define dg-status-no-more-data-if-mdb-notfound (if dg-mdb-status-notfound? (status-set-both dg-status-group-dg dg-status-id-no-more-data))) (pre-define dg-status-success-if-mdb-notfound (if dg-mdb-status-notfound? (status-set-id status-id-success))) (pre-define dg-status-success-if-no-more-data (if (status-id-is? dg-status-id-no-more-data) (struct-set status id status-id-success))) (pre-define dg-mdb-status-success? (status-id-is? MDB-SUCCESS)) (pre-define dg-mdb-status-failure? (not dg-mdb-status-success?)) (pre-define dg-mdb-status-notfound? (status-id-is? MDB-NOTFOUND)) (pre-define (dg-mdb-status-set-id-goto id) (status-set-both-goto dg-status-group-lmdb id)) (pre-define (dg-mdb-status-require! expression) (status-set-id expression) (if dg-mdb-status-failure? (status-set-group-goto dg-status-group-lmdb))) (pre-define dg-mdb-status-require (if dg-mdb-status-failure? (status-set-group-goto dg-status-group-lmdb))) (pre-define dg-mdb-status-require-read (if (not (or dg-mdb-status-success? dg-mdb-status-notfound?)) (status-set-group-goto dg-status-group-lmdb))) (pre-define (dg-mdb-status-require-read! expression) (status-set-id expression) dg-mdb-status-require-read) (pre-define dg-mdb-status-require-notfound (if (not dg-mdb-status-notfound?) (status-set-group-goto dg-status-group-lmdb)))