-# Copyright (c) 2009, 2010 Nicira Networks
+# Copyright (c) 2009, 2010, 2011 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
import ovs.json
+
class Error(Exception):
def __init__(self, msg, json=None, tag=None):
- Exception.__init__(self)
self.msg = msg
self.json = json
if tag is None:
else:
self.tag = tag
- def __str__(self):
+ # Compose message.
syntax = ""
if self.json is not None:
- syntax = "syntax \"%s\": " % ovs.json.to_string(self.json)
- return "%s%s: %s" % (syntax, self.tag, self.msg)
+ syntax = 'syntax "%s": ' % ovs.json.to_string(self.json)
+ Exception.__init__(self, "%s%s: %s" % (syntax, self.tag, self.msg))