Method: DBGeni::Migrator::Sybase#migration_errors
- Defined in:
- lib/dbgeni/migrators/sybase.rb
permalink #migration_errors ⇒ Object
def rollback(migration, force=nil) end
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dbgeni/migrators/sybase.rb', line 17 def migration_errors error = '' # The first error is the one to report - with sybase isql doesn't stop on errors # The error lines tend to look like: # Msg 156, Level 15, State 2: # Server 'WW637L18714A', Line 2: # Incorrect syntax near the keyword 'table'. begin fh = File.open(@logfile, 'r') # search for a line starting Msg or Error and then grab the next 2 lines to make up the error. while (l = fh.readline) if l =~ /^(Msg|Error)\s\d+/ error = l break end end unless error == '' # if an error was found, add the next two lines to the error message error << fh.readline error << fh.readline end rescue ::EOFError # reached the end of file before a full error message was found ... # Just catch and move on ... ensure fh.close if fh end error end |