move exception_to_str behavior to common place
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| Glance |
Wishlist
|
Unassigned |
Bug Description
The function exception_to_str() has a history https:/
LOG.warn('The bug is %s: ' % e)
to
LOG.warn(The bug is %s: ' % exception_
It's not so concise, because the log message writer would care about python encoding issues when they writing something. We could move the behavior of using this function to GlanceException
Changed in glance: | |
importance: | Undecided → Wishlist |
Kun Huang (academicgareth) wrote : | #2 |
@Ian
Seeing the history, the logging module doesn't encode/decode strings very well. So we have to encode/decode before the log behavior. Putting this in common place could make codes clean.
But I found __init__ is not the good choice. __str__/__unicode__ is better in this case, because:
LOG(err) calls err.__str__ and would fail in some character. So the duty to pass correct encoded or decoded string is the duty of __str__
This isn't used in GlanceException though so it doesn't make sense to move it there. Could you expand on how this would be worthwhile in GlanceException .__init_ _?