improved error handling

This commit is contained in:
Luc De Meyer
2018-08-09 20:43:24 +02:00
committed by Saran440
parent 2ab4d6d46b
commit 44a0be4e8e

View File

@@ -43,14 +43,14 @@ class AbstractReportXlsx(ReportXlsx):
else: else:
if len(name) > max_chars: if len(name) > max_chars:
raise UserError(_( raise UserError(_(
"Programming Error." "Programming Error:\n\n"
"\nExcel Sheet name '%s' should not exceed %s characters." "Excel Sheet name '%s' should not exceed %s characters."
) % (name, max_chars)) ) % (name, max_chars))
special_chars = pattern.findall(name) special_chars = pattern.findall(name)
if special_chars: if special_chars:
raise UserError(_( raise UserError(_(
"Programming Error." "Programming Error:\n\n"
"\nExcel Sheet name '%s' contains unsupported special " "Excel Sheet name '%s' contains unsupported special "
"characters: '%s'." "characters: '%s'."
) % (name, special_chars)) ) % (name, special_chars))
return name return name
@@ -445,10 +445,9 @@ class AbstractReportXlsx(ReportXlsx):
for pos, col in enumerate(wl): for pos, col in enumerate(wl):
if col not in col_specs: if col not in col_specs:
raise UserError(_( raise UserError(_(
"%s - Programming Error: " "Programming Error:\n\n"
"the '%' column is not defined the worksheet " "The '%s' column is not defined in the worksheet "
"column specifications.") "column specifications.") % col)
% (__name__, col))
ws.set_column(pos, pos, col_specs[col]['width']) ws.set_column(pos, pos, col_specs[col]['width'])
def _write_ws_title(self, ws, row_pos, ws_params, merge_range=False): def _write_ws_title(self, ws, row_pos, ws_params, merge_range=False):
@@ -460,10 +459,9 @@ class AbstractReportXlsx(ReportXlsx):
title = ws_params.get('title') title = ws_params.get('title')
if not title: if not title:
raise UserError(_( raise UserError(_(
"%s - Programming Error: " "Programming Error:\n\n"
"the 'title' parameter is mandatory " "The 'title' parameter is mandatory "
"when calling the '_write_ws_title' method.") "when calling the '_write_ws_title' method."))
% __name__)
if merge_range: if merge_range:
wl = ws_params.get('wanted_list') wl = ws_params.get('wanted_list')
if wl and len(wl) > 1: if wl and len(wl) > 1:
@@ -488,10 +486,9 @@ class AbstractReportXlsx(ReportXlsx):
for col in wl: for col in wl:
if col not in col_specs: if col not in col_specs:
raise UserError(_( raise UserError(_(
"%s - Programming Error: " "Programming Error:\n\n"
"the '%' column is not defined the worksheet " "The '%s' column is not defined the worksheet "
"column specifications.") "column specifications.") % col)
% (__name__, col))
colspan = col_specs[col].get('colspan') or 1 colspan = col_specs[col].get('colspan') or 1
cell_spec = col_specs[col].get(col_specs_section) or {} cell_spec = col_specs[col].get(col_specs_section) or {}
if not cell_spec: if not cell_spec: