From e4e89b0bc9c3a8c18cae358375a148a9b43a89f6 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Sat, 17 Dec 2011 21:41:27 -0700 Subject: [PATCH] removed unstable/exn (moved code to single use in web-server) --- collects/tests/unstable/exn.rkt | 12 ----- collects/unstable/exn.rkt | 32 ------------- collects/unstable/scribblings/exn.scrbl | 47 ------------------- collects/unstable/scribblings/unstable.scrbl | 1 - .../unstable/tests/test-docs-complete.rkt | 1 - collects/web-server/private/util.rkt | 23 ++++++++- 6 files changed, 21 insertions(+), 95 deletions(-) delete mode 100644 collects/tests/unstable/exn.rkt delete mode 100644 collects/unstable/exn.rkt delete mode 100644 collects/unstable/scribblings/exn.scrbl diff --git a/collects/tests/unstable/exn.rkt b/collects/tests/unstable/exn.rkt deleted file mode 100644 index 63e86c127d..0000000000 --- a/collects/tests/unstable/exn.rkt +++ /dev/null @@ -1,12 +0,0 @@ -#lang racket - -(require rackunit rackunit/text-ui unstable/exn "helpers.rkt") - -(run-tests - (test-suite "exn.rkt" - (test-suite "try" - (test-ok (try (+ 1 2))) - (test-bad (try (+ 'a 'b))) - (test-ok (try (+ 'a 'b) (+ 3 4))) - (test-ok (try (+ 1 2) (+ 'a 'b))) - (test-bad (try (+ 'a 'b) (+ 'c 'd)))))) diff --git a/collects/unstable/exn.rkt b/collects/unstable/exn.rkt deleted file mode 100644 index 8f8820dbc8..0000000000 --- a/collects/unstable/exn.rkt +++ /dev/null @@ -1,32 +0,0 @@ -#lang racket/base -(require racket/contract/base - (for-syntax racket/base)) - -;; network-error: symbol string . values -> void -;; throws a formatted exn:fail:network -(define (network-error src fmt . args) - (raise (make-exn:fail:network (format "~a: ~a" src (apply format fmt args)) - (current-continuation-marks)))) - -;; exn->string : (or/c exn any) -> string -(define (exn->string exn) - (if (exn? exn) - (parameterize ([current-error-port (open-output-string)]) - ((error-display-handler) (exn-message exn) exn) - (get-output-string (current-error-port))) - (format "~s\n" exn))) -;; Eli: (or/c exn any)?? - -(define-syntax (try stx) - (syntax-case stx () - [(_ e) #'(#%expression e)] - [(_ e0 e ...) - (syntax/loc stx - (with-handlers* ([exn:fail? (lambda (x) (try e ...))]) - (#%expression e0)))])) - -(provide try) - -(provide/contract - [network-error (->* [symbol? string?] [] #:rest list? void?)] - [exn->string (-> any/c string?)]) diff --git a/collects/unstable/scribblings/exn.scrbl b/collects/unstable/scribblings/exn.scrbl deleted file mode 100644 index 4b54b634a6..0000000000 --- a/collects/unstable/scribblings/exn.scrbl +++ /dev/null @@ -1,47 +0,0 @@ -#lang scribble/manual -@(require scribble/eval "utils.rkt" - (for-label unstable/exn racket/contract racket/base)) - -@(define the-eval (make-base-eval)) -@(the-eval '(require unstable/exn)) - -@title[#:tag "exn"]{Exceptions} - -@defmodule[unstable/exn] - -@unstable-header[] - -@defproc[(network-error [s symbol?] - [fmt string?] - [v any/c] ...) - void]{ - Like @racket[error], but throws a @racket[exn:fail:network]. -} - -@defproc[(exn->string [exn (or/c exn? any/c)]) - string?]{ - Formats @racket[exn] with @racket[(error-display-handler)] as a string. -} - -@addition[@author+email["Carl Eastlund" "cce@racket-lang.org"]] - -@defform[(try expr ...+)]{ - -Executes the first expression @racket[expr] in the sequence, producing its -result value(s) if it returns any. If it raises an exception instead, -@racket[try] continues with the next @racket[expr]. Exceptions raised by -intermediate expressions are reported to the @tech[#:doc '(lib -"scribblings/reference/reference.scrbl")]{current logger} at the @racket['debug] -level before continuing. Exceptions raised by the final expression are not -caught by @racket[try]. - -@defexamples[ -#:eval the-eval -(try (+ 1 2) (+ 3 4)) -(try (+ 'one 'two) (+ 3 4)) -(try (+ 'one 'two) (+ 'three 'four)) -] - -} - -@(close-eval the-eval) diff --git a/collects/unstable/scribblings/unstable.scrbl b/collects/unstable/scribblings/unstable.scrbl index 752c3df03f..0cf3b6347f 100644 --- a/collects/unstable/scribblings/unstable.scrbl +++ b/collects/unstable/scribblings/unstable.scrbl @@ -78,7 +78,6 @@ Keep documentation and tests up to date. @include-section["prop-contract.scrbl"] @include-section["debug.scrbl"] @include-section["define.scrbl"] -@include-section["exn.scrbl"] @include-section["file.scrbl"] @include-section["find.scrbl"] @include-section["future.scrbl"] diff --git a/collects/unstable/tests/test-docs-complete.rkt b/collects/unstable/tests/test-docs-complete.rkt index b463336c41..54ec423c70 100644 --- a/collects/unstable/tests/test-docs-complete.rkt +++ b/collects/unstable/tests/test-docs-complete.rkt @@ -19,7 +19,6 @@ (check-docs (quote unstable/function)) (check-docs (quote unstable/find)) (check-docs (quote unstable/file)) -(check-docs (quote unstable/exn)) (check-docs (quote unstable/debug)) (check-docs (quote unstable/contract)) (check-docs (quote unstable/class-iop)) diff --git a/collects/web-server/private/util.rkt b/collects/web-server/private/util.rkt index 0f8e914f38..3ddd8ea2b7 100644 --- a/collects/web-server/private/util.rkt +++ b/collects/web-server/private/util.rkt @@ -1,7 +1,6 @@ #lang racket/base (require unstable/bytes unstable/contract - unstable/exn unstable/list unstable/path unstable/string @@ -10,8 +9,28 @@ (all-from-out unstable/bytes unstable/contract - unstable/exn unstable/list unstable/path unstable/string unstable/net/url)) + +(require racket/contract/base + (for-syntax racket/base)) + +;; network-error: symbol string . values -> void +;; throws a formatted exn:fail:network +(define (network-error src fmt . args) + (raise (make-exn:fail:network (format "~a: ~a" src (apply format fmt args)) + (current-continuation-marks)))) + +;; exn->string : (or/c exn any) -> string +(define (exn->string exn) + (if (exn? exn) + (parameterize ([current-error-port (open-output-string)]) + ((error-display-handler) (exn-message exn) exn) + (get-output-string (current-error-port))) + (format "~s\n" exn))) + +(provide/contract + [network-error (->* [symbol? string?] [] #:rest list? void?)] + [exn->string (-> any/c string?)])