* New primop "throw <string>" to throw an error. This is like abort,
only thrown errors are caught by the top-level derivation evaluation in nix-env -qa / -i.
This commit is contained in:
		
							parent
							
								
									0a8eeea9d8
								
							
						
					
					
						commit
						5f2492eaec
					
				
					 3 changed files with 13 additions and 0 deletions
				
			
		|  | @ -269,6 +269,14 @@ static Expr prim_abort(EvalState & state, const ATermVector & args) | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| static Expr prim_throw(EvalState & state, const ATermVector & args) | ||||
| { | ||||
|     PathSet context; | ||||
|     throw ThrownError(format("user-thrown exception: `%1%'") % | ||||
|         evalString(state, args[0], context)); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /* Return an environment variable.  Use with care. */ | ||||
| static Expr prim_getEnv(EvalState & state, const ATermVector & args) | ||||
| { | ||||
|  | @ -878,6 +886,7 @@ void EvalState::addPrimOps() | |||
|     addPrimOp("isNull", 1, prim_isNull); | ||||
|     addPrimOp("dependencyClosure", 1, prim_dependencyClosure); | ||||
|     addPrimOp("abort", 1, prim_abort); | ||||
|     addPrimOp("throw", 1, prim_throw); | ||||
|     addPrimOp("__getEnv", 1, prim_getEnv); | ||||
| 
 | ||||
|     addPrimOp("relativise", 2, prim_relativise); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue