@@ -156,6 +156,7 @@ the `eask-start' execution.")
156156(defun eask-log-level-p () (eask--flag " --log-level" )) ; --log-level
157157(defun eask-no-log-level-p () (eask--flag " --no-log-level" )) ; --no-log-level
158158(defun eask-no-color-p () (eask--flag " --no-color" )) ; --no-color
159+ (defun eask-allow-error-p () (eask--flag " --allow-error" )) ; --allow-error
159160
160161; ;; String (with arguments)
161162(defun eask-proxy () (eask--flag-value " --proxy" )) ; --proxy
@@ -212,7 +213,8 @@ other scripts internally. See function `eask-call'.")
212213 " --debug" " --strict"
213214 " --timestamps" " --no-timestamps"
214215 " --log-level" " --no-log-level"
215- " --no-color" ))
216+ " --no-color"
217+ " --allow-error" ))
216218 " List of boolean type options" )
217219
218220(defconst eask--option-args
@@ -428,16 +430,28 @@ Eask file in the workspace."
428430
429431(defun eask--exit (&rest _ ) " Send exit code." (kill-emacs 1 ))
430432
431- (defun eask--trigger-error (&rest args )
432- " Trigger error."
433+ (defun eask--trigger-error ()
434+ " Trigger error at the right time."
435+ (if (eask-allow-error-p)
436+ (add-hook 'eask-after-command-hook #'eask--exit )
437+ (eask--exit)))
438+
439+ (defun eask--error (fnc &rest args )
440+ " On error."
433441 (unless eask--ignore-error-p
434442 ; ; XXX Log out the error explicitly, so the user will know what causes Emacs
435443 ; ; to crash.
436- (let ((eask-log-level t ))
437- (eask-error " %s" (apply #'format-message args)))
438- (add-hook 'eask-after-command-hook #'eask--exit )))
444+ (eask-msg " %s" (eask--asni 'error (apply #'format-message args)))
445+ (eask--trigger-error))
446+ (when debug-on-error (apply fnc args)))
447+
448+ (advice-add 'error :around #'eask--error )
439449
440- (advice-add 'error :before #'eask--trigger-error )
450+ (defun eask--warn (&rest args )
451+ " On warn."
452+ (eask-msg " %s" (eask--asni 'warn (apply #'format-message args))))
453+
454+ (advice-add 'warn :override #'eask--warn )
441455
442456; ;
443457; ;; Verbosity
@@ -498,13 +512,20 @@ and the BODY will be executed silently."
498512(defun eask-log (msg &rest args ) (apply #'eask--msg 'log " [LOG]" msg args))
499513(defun eask-info (msg &rest args ) (apply #'eask--msg 'info " [INFO]" msg args))
500514(defun eask-warn (msg &rest args ) (apply #'eask--msg 'warn " [WARNING]" msg args))
501- (defun eask-error (msg &rest args ) (apply #'eask--msg 'error " [ERROR]" msg args))
515+ (defun eask-error (msg &rest args )
516+ (apply #'eask--msg 'error " [ERROR]" msg args)
517+ (eask--trigger-error))
518+
519+ (defun eask--asni (symbol string )
520+ " Wrap STRING with log SYMBOL."
521+ (let ((ansi-function (cdr (assq symbol eask-level-color))))
522+ (funcall ansi-function string)))
502523
503524(defun eask--msg (symbol prefix msg &rest args )
504525 " If LEVEL is at or below `eask-verbosity' , log message."
505526 (eask-with-verbosity symbol
506- (let* ((ansi-function ( cdr ( assq symbol eask-level-color) ))
507- (output (funcall ansi-function ( apply # ' eask--format prefix msg args) )))
527+ (let* ((string ( apply # ' eask--format prefix msg args ))
528+ (output (eask--asni symbol string )))
508529 (message " %s " output))))
509530
510531(defun eask--format (prefix fmt &rest args )
0 commit comments