Add error code when synchornization fails to overwrite table

pull/13400/head
Javier Torres 7 years ago
parent 7c59280f47
commit 30efa625cf

@ -8,6 +8,7 @@ module CartoDB
STATEMENT_TIMEOUT = (1.hour * 1000).freeze
DESTINATION_SCHEMA = 'public'.freeze
THE_GEOM = 'the_geom'.freeze
OVERWRITE_ERROR = 2013
attr_accessor :table
@ -23,6 +24,7 @@ module CartoDB
overviews_creator: overviews_creator,
log: runner.log
)
@error_code = nil
end
def run(&tracker)
@ -78,12 +80,13 @@ module CartoDB
@table_setup.fix_oid(table_name)
@table_setup.update_cdb_tablemetadata(table_name)
rescue => exception
@error_code = OVERWRITE_ERROR
puts "Sync overwrite ERROR: #{exception.message}: #{exception.backtrace.join}"
# Gets all attributes in the result except for 'log_trace', as it is too long for Rollbar
result_hash = CartoDB::Importer2::Result::ATTRIBUTES.map { |m| [m, result.send(m)] if m != 'log_trace' }
.compact.to_h
CartoDB::Logger.error(message: 'Error in sync cartodbfy',
CartoDB::Logger.error(message: 'Error in sync overwrite',
exception: exception,
user: user,
table: table_name,
@ -283,8 +286,6 @@ module CartoDB
def drop(table_name)
database.execute(%Q(DROP TABLE "#{user.database_schema}"."#{table_name}"))
rescue
self
end
def exists?(table_name)
@ -296,7 +297,7 @@ module CartoDB
end
def error_code
runner.results.map(&:error_code).compact.first
@error_code || runner.results.map(&:error_code).compact.first
end
def runner_log_trace

@ -219,6 +219,11 @@ module CartoDB
what_about: "The import failed because you are trying to overwrite a table but the data you are providing is not compatible with the data that table already has. You may me changing some types or removing a column. Please check and try again",
source: ERROR_SOURCE_USER
},
2013 => {
title: 'Cannot overwrite table',
what_about: "The synchronization failed because the destination table could not be overwritten. Please make sure that there are no database objects (e.g: views) that depend on it.",
source: ERROR_SOURCE_USER
},
3007 => {
title: 'JSON may not be valid GeoJSON',
what_about: "We can only import GeoJSON formated JSON files. See if the source of this data supports GeoJSON or another file format for download.",

Loading…
Cancel
Save