Skip to content

Commit fd899ab

Browse files
committed
Merge pull request #15 from Kuniwak/custom-exception
Use custom exception instead of just Exception
2 parents b92f62c + 1f048aa commit fd899ab

File tree

3 files changed

+90
-84
lines changed

3 files changed

+90
-84
lines changed

py/pycompiler.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ function s:PythonCompiler.compile_try(node)
453453
endfunction
454454

455455
function s:PythonCompiler.compile_throw(node)
456-
call self.out('raise Exception(%s)', self.compile(a:node.left))
456+
call self.out('raise VimLParserException(%s)', self.compile(a:node.left))
457457
endfunction
458458

459459
function s:PythonCompiler.compile_echo(node)
@@ -477,7 +477,7 @@ endfunction
477477

478478
function s:PythonCompiler.compile_echoerr(node)
479479
let list = map(a:node.list, 'self.compile(v:val)')
480-
call self.out('raise Exception([%s]))', join(list, ', '))
480+
call self.out('raise VimLParserException([%s]))', join(list, ', '))
481481
endfunction
482482

483483
function s:PythonCompiler.compile_execute(node)

py/vimlfunc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def main():
1212
for line in c.compile(p.parse(r)):
1313
print(line)
1414

15+
class VimLParserException(Exception):
16+
pass
17+
1518
class AttributeDict(dict):
1619
__getattr__ = dict.__getitem__
1720
__setattr__ = dict.__setitem__
@@ -146,7 +149,7 @@ def viml_remove(lst, idx):
146149
def viml_split(s, sep):
147150
if sep == "\\zs":
148151
return s
149-
raise Exception("NotImplemented")
152+
raise VimLParserException("NotImplemented")
150153

151154
def viml_str2nr(s, base=10):
152155
return int(s, base)
@@ -173,5 +176,5 @@ def viml_type(obj):
173176
return 4
174177
elif isinstance(obj, float):
175178
return 5
176-
raise Exception('Unknown Type')
179+
raise VimLParserException('Unknown Type')
177180

0 commit comments

Comments
 (0)