scheduling etc
[software/python-on-guile.git] / modules / language / python / exceptions.scm
1 (define-module (language python exceptions)
2 #:use-module (oop pf-objects)
3 #:use-module (oop goops)
4 #:export (StopIteration GeneratorExit RuntimeError
5 Exception ValueError TypeError
6 IndexError KeyError AttributeError
7 SyntaxError SystemException
8 OSError ProcessLookupError PermissionError
9 None))
10
11 (define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
12
13 (define StopIteration 'StopIteration)
14 (define GeneratorExit 'GeneratorExit)
15 (define SystemException 'SystemException)
16 (define RuntimeError 'RuntimeError)
17 (define IndexError 'IndexError)
18 (define ValueError 'ValueError)
19 (define None 'None)
20 (define KeyError 'KeyError)
21 (define TypeError 'TypeError)
22 (define AttributeError 'AttributeError)
23 (define SyntaxError 'SyntaxError)
24 (define OSError 'OSError)
25 (define ProcessLookupError 'ProcessLookupError)
26 (define PermissionError 'PermissionError)
27
28 (define-python-class Exception ()
29 (define __init__
30 (case-lambda
31 ((self)
32 (values))
33 ((self val . l)
34 (set self 'value val))))
35
36 (define __repr__
37 (lambda (self)
38 (aif it (ref self 'value #f)
39 (format #f "~a:~a"
40 (ref self '__name__) it)
41 (format #f "~a"
42 (ref self '__name__))))))
43
44
45
46
47