Edgewall Software

Opened 6 years ago

Last modified 2 years ago

#11419 closed enhancement

More user-friendly error message from trac-admin console commands when IntegrityError in database — at Initial Version

Reported by: Ryan J Ollos Owned by:
Priority: normal Milestone: 1.3.2
Component: admin/console Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description

Console admin milestone add operation could report a nicer error when milestone already exists. For example,

$ trac-admin tracdev milestone add milestone1
IntegrityError: column name is not unique
16:29:47 Trac[console] ERROR: Exception in trac-admin command: 
Traceback (most recent call last):
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/admin/console.py", line 110, in onecmd
    rv = cmd.Cmd.onecmd(self, line) or 0
  File "/usr/lib/python2.7/cmd.py", line 220, in onecmd
    return self.default(line)
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/admin/console.py", line 286, in default
    return self.cmd_mgr.execute_command(*args)
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/admin/api.py", line 127, in execute_command
    return f(*fargs)
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/ticket/admin.py", line 411, in _do_add
    milestone.insert()
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/ticket/model.py", line 1042, in insert
    to_utimestamp(self.completed), self.description))
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/db/util.py", line 121, in execute
    cursor.execute(query, params)
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/db/util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/db/sqlite_backend.py", line 78, in execute
    result = PyFormatCursor.execute(self, *args)
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/db/sqlite_backend.py", line 56, in execute
    args or [])
  File "/home/user/Workspace/t2311/teo-rjollos.git/trac/db/sqlite_backend.py", line 48, in _rollback_on_error
    return function(self, *args, **kwargs)
IntegrityError: column name is not unique

Instead, we'll aim for something like:

$ trac-admin tracdev milestone add milestone1
TracError: milestone "milestone1" already exists

Change History (0)

Note: See TracTickets for help on using tickets.