ui: Improve error reporting for 'read/eval'.
The effect is visible on commands like: guix build -e '(+ 2 "foo")' guix build -e '()' * guix/ui.scm (read/eval): Change handler to properly report syntax errors and use 'display-error' for other errors.
This commit is contained in:
		
							parent
							
								
									cdb5b075d5
								
							
						
					
					
						commit
						41766807d0
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		
							
								
								
									
										10
									
								
								guix/ui.scm
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								guix/ui.scm
									
										
									
									
									
								
							| 
						 | 
					@ -446,8 +446,14 @@ interpreted."
 | 
				
			||||||
      (lambda ()
 | 
					      (lambda ()
 | 
				
			||||||
        (eval exp (force %guix-user-module)))
 | 
					        (eval exp (force %guix-user-module)))
 | 
				
			||||||
      (lambda args
 | 
					      (lambda args
 | 
				
			||||||
        (leave (_ "failed to evaluate expression `~a': ~s~%")
 | 
					        (report-error (_ "failed to evaluate expression '~a':~%") exp)
 | 
				
			||||||
               exp args)))))
 | 
					        (match args
 | 
				
			||||||
 | 
					          (('syntax-error proc message properties form . rest)
 | 
				
			||||||
 | 
					           (report-error (_ "syntax error: ~a~%") message))
 | 
				
			||||||
 | 
					          ((error args ...)
 | 
				
			||||||
 | 
					           (apply display-error #f (current-error-port) args))
 | 
				
			||||||
 | 
					          (what? #f))
 | 
				
			||||||
 | 
					        (exit 1)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define (read/eval-package-expression str)
 | 
					(define (read/eval-package-expression str)
 | 
				
			||||||
  "Read and evaluate STR and return the package it refers to, or exit an
 | 
					  "Read and evaluate STR and return the package it refers to, or exit an
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue