| 
									
										
										
										
											2008-05-30 19:00:42 -04:00
										 |  |  | ! Copyright (C) 2008 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  | USING: accessors kernel continuations fry words ;
 | 
					
						
							| 
									
										
										
										
											2008-05-30 19:00:42 -04:00
										 |  |  | IN: db.errors | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ERROR: db-error ;
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | ERROR: sql-error location ;
 | 
					
						
							| 
									
										
										
										
											2008-05-30 19:00:42 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ERROR: bad-schema ;
 | 
					
						
							| 
									
										
										
										
											2009-02-20 21:40:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  | ERROR: sql-unknown-error < sql-error message ;
 | 
					
						
							|  |  |  | : <sql-unknown-error> ( message -- error )
 | 
					
						
							|  |  |  |     \ sql-unknown-error new
 | 
					
						
							|  |  |  |         swap >>message ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | ERROR: sql-table-exists < sql-error table ;
 | 
					
						
							|  |  |  | : <sql-table-exists> ( table -- error )
 | 
					
						
							|  |  |  |     \ sql-table-exists new
 | 
					
						
							|  |  |  |         swap >>table ;
 | 
					
						
							| 
									
										
										
										
											2009-02-20 21:40:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | ERROR: sql-table-missing < sql-error table ;
 | 
					
						
							|  |  |  | : <sql-table-missing> ( table -- error )
 | 
					
						
							|  |  |  |     \ sql-table-missing new
 | 
					
						
							|  |  |  |         swap >>table ;
 | 
					
						
							| 
									
										
										
										
											2009-02-20 21:40:17 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:22:51 -05:00
										 |  |  | ERROR: sql-syntax-error < sql-error message ;
 | 
					
						
							|  |  |  | : <sql-syntax-error> ( message -- error )
 | 
					
						
							|  |  |  |     \ sql-syntax-error new
 | 
					
						
							|  |  |  |         swap >>message ;
 | 
					
						
							| 
									
										
										
										
											2009-02-21 22:59:23 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ERROR: sql-function-exists < sql-error message ;
 | 
					
						
							|  |  |  | : <sql-function-exists> ( message -- error )
 | 
					
						
							|  |  |  |     \ sql-function-exists new
 | 
					
						
							|  |  |  |         swap >>message ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ERROR: sql-function-missing < sql-error message ;
 | 
					
						
							|  |  |  | : <sql-function-missing> ( message -- error )
 | 
					
						
							|  |  |  |     \ sql-function-missing new
 | 
					
						
							|  |  |  |         swap >>message ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : ignore-error ( quot word -- )
 | 
					
						
							|  |  |  |     '[ dup _ execute [ drop ] [ rethrow ] if ] recover ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : ignore-table-exists ( quot -- )
 | 
					
						
							|  |  |  |     \ sql-table-exists? ignore-error ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : ignore-table-missing ( quot -- )
 | 
					
						
							|  |  |  |     \ sql-table-missing? ignore-error ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : ignore-function-exists ( quot -- )
 | 
					
						
							|  |  |  |     \ sql-function-exists? ignore-error ; inline
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : ignore-function-missing ( quot -- )
 | 
					
						
							|  |  |  |     \ sql-function-missing? ignore-error ; inline
 |