(define-module (language python exceptions) #:use-module (oop pf-objects) #:use-module (oop goops) #:export (StopIteration GeneratorExit RuntimeError Exception ValueError TypeError IndexError KeyError AttributeError SyntaxError SystemException None)) (define-syntax-rule (aif it p x y) (let ((it p)) (if it x y))) (define StopIteration 'StopIteration) (define GeneratorExit 'GeneratorExit) (define SystemException 'SystemException) (define RuntimeError 'RuntimeError) (define IndexError 'IndexError) (define ValueError 'ValueError) (define None 'None) (define KeyError 'KeyError) (define TypeError 'TypeError) (define AttributeError 'AttributeError) (define SyntaxError 'SyntaxError) (define-python-class Exception () (define __init__ (case-lambda ((self) (values)) ((self val . l) (set self 'value val)))) (define __repr__ (lambda (self) (aif it (ref self 'value #f) (format #f "~a:~a" (ref self '__name__) it) (format #f "~a" (ref self '__name__))))))