如何在此球拍代码中添加错误处理?

时间:2014-12-03 16:29:14

标签: parsing error-handling racket

这是一个用球拍脚本制作的雷达解析器,通过tcp连接到DCS世界(飞行模拟器视频游戏)如何对此代码实施错误检查?错误处理程序的过程将检查什么以及过程应该作为语句输出什么?

 (define/public (parse)
            ; needs error checking
            (if (and (equal? jsexpr (json-null)) (not (equal? jsonstr "")))
             (set! jsexpr (string->jsexpr jsonstr) )
          null)

        (set! azimuth (hash-ref jsexpr 'Azimuth) )
        (set! id (hash-ref jsexpr 'ID) )
        (set! power (hash-ref jsexpr 'Power) )
        (set! priority (hash-ref jsexpr 'Priority) )
        (set! signaltype (hash-ref jsexpr 'SignalType) )
        (set! radartype (hash-ref jsexpr 'Type) )
        (if (member 'TypeInts (hash-keys jsexpr))
          (set! typeints (hash-ref jsexpr 'TypeInts))
          null)
        (set! airborne (airborne-type radartype typeints) )
        ;(set! highpriority (high-priority this typeints))
        (set! awacs (if (and
                  (= (car typeints) 1)
                  (= (cadr typeints) 1)
                  (= (caddr typeints) 5)
                 ) #t #f))
        (set! tracking (if 
                 ( and (equal? signaltype "lock") (equal? (modulo i 5) 0))
                 #t 
                 #f
                 )
          )

0 个答案:

没有答案