Work on ignoring errors and giving warnings.
This commit is contained in:
parent
82319aaa4d
commit
06159627aa
1 changed files with 19 additions and 7 deletions
|
@ -28,6 +28,8 @@
|
||||||
(module
|
(module
|
||||||
member-file
|
member-file
|
||||||
(
|
(
|
||||||
|
*member-file-context*
|
||||||
|
*member-file-check-syntax*
|
||||||
load-member-file
|
load-member-file
|
||||||
member-file-tests!
|
member-file-tests!
|
||||||
)
|
)
|
||||||
|
@ -54,6 +56,12 @@
|
||||||
;; Configuration of error reporting
|
;; Configuration of error reporting
|
||||||
(define *member-file-context* (make-parameter 3))
|
(define *member-file-context* (make-parameter 3))
|
||||||
|
|
||||||
|
;; Tolerance to formal errors (invalid key or key without value):
|
||||||
|
;; 'error - show source and exits with error
|
||||||
|
;; 'warning - show source and error, continue
|
||||||
|
;; 'quiet - ignore
|
||||||
|
(define *member-file-check-syntax* (make-parameter 'error))
|
||||||
|
|
||||||
;; Derived keys
|
;; Derived keys
|
||||||
(define start/stop-keys-keys
|
(define start/stop-keys-keys
|
||||||
(map
|
(map
|
||||||
|
@ -79,14 +87,18 @@
|
||||||
(car (string-chop l si)))
|
(car (string-chop l si)))
|
||||||
l)))
|
l)))
|
||||||
|
|
||||||
|
;; Reports error with highlighted source line(s), configured via the
|
||||||
|
;; *member-file-check-syntax* parameter.
|
||||||
(define (report-line-error file-name lines highlights message)
|
(define (report-line-error file-name lines highlights message)
|
||||||
(print "Error in " file-name ": " message)
|
(when (not (eq? (*member-file-check-syntax*) 'quiet))
|
||||||
(newline)
|
(print "Error in " file-name ": " message)
|
||||||
(print-source-listing lines highlights
|
(newline)
|
||||||
(*member-file-context*)
|
(print-source-listing lines highlights
|
||||||
(ansi #:red #:bold) (ansi #:default)
|
(*member-file-context*)
|
||||||
"" "" "...")
|
(ansi #:red #:bold) (ansi #:default)
|
||||||
(exit 1))
|
"" "" "..."))
|
||||||
|
(when (eq? (*member-file-check-syntax*) 'error)
|
||||||
|
(exit 1)))
|
||||||
|
|
||||||
;; Parses given key-value line. Key is up to first space, value is the
|
;; Parses given key-value line. Key is up to first space, value is the
|
||||||
;; rest of the line. If the line doesn't contain anything, returns #f.
|
;; rest of the line. If the line doesn't contain anything, returns #f.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue