Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/error.py

Issue 1410053006: Move third_party/mojo/src/mojo/public to mojo/public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 class Error(Exception): 5 class Error(Exception):
6 """Base class for Mojo IDL bindings parser/generator errors.""" 6 """Base class for Mojo IDL bindings parser/generator errors."""
7 7
8 def __init__(self, filename, message, lineno=None, addenda=None, **kwargs): 8 def __init__(self, filename, message, lineno=None, addenda=None, **kwargs):
9 """|filename| is the (primary) file which caused the error, |message| is the 9 """|filename| is the (primary) file which caused the error, |message| is the
10 error message, |lineno| is the 1-based line number (or |None| if not 10 error message, |lineno| is the 1-based line number (or |None| if not
11 applicable/available), and |addenda| is a list of additional lines to append 11 applicable/available), and |addenda| is a list of additional lines to append
12 to the final error message.""" 12 to the final error message."""
13 Exception.__init__(self, **kwargs) 13 Exception.__init__(self, **kwargs)
14 self.filename = filename 14 self.filename = filename
15 self.message = message 15 self.message = message
16 self.lineno = lineno 16 self.lineno = lineno
17 self.addenda = addenda 17 self.addenda = addenda
18 18
19 def __str__(self): 19 def __str__(self):
20 if self.lineno: 20 if self.lineno:
21 s = "%s:%d: Error: %s" % (self.filename, self.lineno, self.message) 21 s = "%s:%d: Error: %s" % (self.filename, self.lineno, self.message)
22 else: 22 else:
23 s = "%s: Error: %s" % (self.filename, self.message) 23 s = "%s: Error: %s" % (self.filename, self.message)
24 return "\n".join([s] + self.addenda) if self.addenda else s 24 return "\n".join([s] + self.addenda) if self.addenda else s
25 25
26 def __repr__(self): 26 def __repr__(self):
27 return str(self) 27 return str(self)
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/__init__.py ('k') | mojo/public/tools/bindings/pylib/mojom/fileutil.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698