Set IntegrityError as UserError

This commit is contained in:
Cédric Krier committed 2008-07-24 18:40:22 +02:00
1 parent dfe9d4418c
commit 2dfd7d5e92
4 files changed
+29 -2

No files matched your search

+13 -1
View File
@@ -6,7 +6,7 @@ from trytond.netsvc import Service, LocalService, Logger, LOG_ERROR
from trytond import pooler
import copy
import sys
from psycopg2 import IntegrityError
from trytond.sql_db import IntegrityError
from trytond.tools import UpdateableDict
import traceback
from trytond.tools import Cache
@@ -50,11 +50,17 @@ class OSVService(Service):
'ConcurrencyException') \
and not CONFIG['verbose']:
raise
if isinstance(exception, IntegrityError) and not CONFIG['verbose']:
raise Exception('UserError', 'Constraint Error',
*exception.args)
tb_s = reduce(lambda x, y: x+y,
traceback.format_exception(*sys.exc_info()))
logger = Logger()
logger.notify_channel("web-services", LOG_ERROR,
'Exception in call: \n' + tb_s)
if isinstance(exception, IntegrityError):
raise Exception('UserError', 'Constraint Error',
*exception.args)
raise
def execute(self, dbname, user, object_name, method, *args, **kargs):
@@ -83,11 +89,17 @@ class OSVService(Service):
'ConcurrencyException') \
and not CONFIG['verbose']:
raise
if isinstance(exception, IntegrityError) and not CONFIG['verbose']:
raise Exception('UserError', 'Constraint Error',
*exception.args)
tb_s = reduce(lambda x, y: x+y,
traceback.format_exception(*sys.exc_info()))
logger = Logger()
logger.notify_channel("web-services", LOG_ERROR,
'Exception in call: \n' + tb_s)
if isinstance(exception, IntegrityError):
raise Exception('UserError', 'Constraint Error',
*exception.args)
raise
return True
+7
View File
@@ -25,6 +25,7 @@ import tempfile
from genshi.filters import Translator
import traceback
from trytond.config import CONFIG
from trytond.sql_db import IntegrityError
MODULE_LIST = []
MODULE_CLASS_LIST = {}
@@ -193,10 +194,16 @@ class ReportService(Service):
'ConcurrencyException') \
and not CONFIG['verbose']:
raise
if isinstance(exception, IntegrityError) and not CONFIG['verbose']:
raise Exception('UserError', 'Constraint Error',
*exception.args)
tb_s = reduce(lambda x, y: x+y,
traceback.format_exception(*sys.exc_info()))
Logger().notify_channel("web-services", LOG_ERROR,
'Exception in call: ' + tb_s)
if isinstance(exception, IntegrityError):
raise Exception('UserError', 'Constraint Error',
*exception.args)
raise
def execute(self, dbname, user, report_name, ids, datas, context=None):
+1
View File
@@ -1,6 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms.
from psycopg2.pool import ThreadedConnectionPool
from psycopg2.extensions import ISOLATION_LEVEL_SERIALIZABLE, cursor
from psycopg2 import IntegrityError
import psycopg2
import re
import os
+8 -1
View File
@@ -7,6 +7,8 @@ from xml import dom
from trytond.osv import OSV
from trytond.config import CONFIG
import sys
from trytond.sql_db import IntegrityError
import traceback
MODULE_LIST = []
MODULE_CLASS_LIST = {}
@@ -37,11 +39,16 @@ class WizardService(Service):
'ConcurrencyException') \
and not CONFIG['verbose']:
raise
import traceback
if isinstance(exception, IntegrityError) and not CONFIG['verbose']:
raise Exception('UserError', 'Constraint Error',
*exception.args)
tb_s = reduce(lambda x, y: x+y,
traceback.format_exception(*sys.exc_info()))
Logger().notify_channel("web-services", LOG_ERROR,
'Exception in call: ' + tb_s)
if isinstance(exception, IntegrityError):
raise Exception('UserError', 'Constraint Error',
*exception.args)
raise
def execute(self, dbname, user, wizard_name, data, state='init',