Debian Codegraph @

core/miku/error.rb

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 module MIKU
3
4
5 class MikuException < Exception
6 end
7
8 class ExceptionDelegator < Exception
9 def initialize(msg, exceptionclass)
10 @exceptionclass = exceptionclass
11 super(msg)
12 end
13
14 def fire(scan)
15 puts self.backtrace.join("\n")
16 raise @exceptionclass.new(to_s, scan)
17 end
18 end
19
20 class SyntaxError < MikuException
21 def initialize(msg, scan)
22 super(msg + " #{scan.staticcode_file} in line #{scan.staticcode_line}\n #{MIKU.unparse(scan)}")
23 end
24 end
25
26 class ArgumentError < MikuException
27 def initialize(msg, scan)
28 super(msg + " #{scan.staticcode_file} in line #{scan.staticcode_line}\n #{MIKU.unparse(scan)}")
29 end
30 end
31
32 class TypeError < MikuException
33 def initialize(msg, scan)
34 super(msg + " #{scan.staticcode_file} in line #{scan.staticcode_line}\n #{MIKU.unparse(scan)}")
35 end
36 end
37
38 def parse_caller(at)
39 if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
40 file = $1
41 line = $2.to_i
42 method = $3
43 [file, line, method]
44 end
45 end
46
47 class NoMithodError < MikuException
48 def initialize(name, scan)
49 super("undefined function '#{name.inspect}' #{scan.staticcode_file rescue '?'} in line #{scan.staticcode_line rescue '?'}\n #{MIKU.unparse(scan)}")
50 end
51 end
52
53 class EndofFile < MikuException
54 end
55
56 end