guix system: Return two values when failing to talk to shepherd.
Before that, when 'guix system reconfigure' failed to talk to shepherd and a 'system-error' was raised, we would get a "too few values returned to continuation" error, which would prevent GRUB from being installed. Reported by fps on #guix. * guix/scripts/system.scm (warn-on-system-error): Remove. (with-shepherd-error-handling): Inline former 'warn-on-system-error'. Return two values when 'system-error' is raised.
This commit is contained in:
		
							parent
							
								
									59fed2b609
								
							
						
					
					
						commit
						af0ba93825
					
				
					 1 changed files with 10 additions and 15 deletions
				
			
		| 
						 | 
					@ -227,25 +227,20 @@ BODY..., and restore them."
 | 
				
			||||||
        (set! %load-path path)
 | 
					        (set! %load-path path)
 | 
				
			||||||
        (set! %load-compiled-path cpath)))))
 | 
					        (set! %load-compiled-path cpath)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define-syntax-rule (warn-on-system-error body ...)
 | 
					 | 
				
			||||||
  (catch 'system-error
 | 
					 | 
				
			||||||
    (lambda ()
 | 
					 | 
				
			||||||
      body ...)
 | 
					 | 
				
			||||||
    (lambda (key proc format-string format-args errno . rest)
 | 
					 | 
				
			||||||
      (warning (_ "while talking to shepherd: ~a~%")
 | 
					 | 
				
			||||||
               (apply format #f format-string format-args))
 | 
					 | 
				
			||||||
      (with-monad %store-monad
 | 
					 | 
				
			||||||
        (return #f)))))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
(define-syntax-rule (with-shepherd-error-handling mbody ...)
 | 
					(define-syntax-rule (with-shepherd-error-handling mbody ...)
 | 
				
			||||||
  "Catch and report Shepherd errors that arise when binding MBODY, a monadic
 | 
					  "Catch and report Shepherd errors that arise when binding MBODY, a monadic
 | 
				
			||||||
expression in %STORE-MONAD."
 | 
					expression in %STORE-MONAD."
 | 
				
			||||||
  (lambda (store)
 | 
					  (lambda (store)
 | 
				
			||||||
    (warn-on-system-error
 | 
					    (catch 'system-error
 | 
				
			||||||
     (guard (c ((shepherd-error? c)
 | 
					      (lambda ()
 | 
				
			||||||
                (values (report-shepherd-error c) store)))
 | 
					        (guard (c ((shepherd-error? c)
 | 
				
			||||||
       (values (run-with-store store (begin mbody ...))
 | 
					                   (values (report-shepherd-error c) store)))
 | 
				
			||||||
               store)))))
 | 
					          (values (run-with-store store (begin mbody ...))
 | 
				
			||||||
 | 
					                  store)))
 | 
				
			||||||
 | 
					      (lambda (key proc format-string format-args errno . rest)
 | 
				
			||||||
 | 
					        (warning (_ "while talking to shepherd: ~a~%")
 | 
				
			||||||
 | 
					                 (apply format #f format-string format-args))
 | 
				
			||||||
 | 
					        (values #f store)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define (report-shepherd-error error)
 | 
					(define (report-shepherd-error error)
 | 
				
			||||||
  "Report ERROR, a '&shepherd-error' error condition object."
 | 
					  "Report ERROR, a '&shepherd-error' error condition object."
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue