From 3d48ef78f67a6fd76496efb385d27635eb50493a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 22 Dec 2014 13:26:20 -0600 Subject: [PATCH] attempt to more closely follow the Reference's "Error Message Conventions" in the contract error messages --- racket/collects/racket/contract/private/blame.rkt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/racket/collects/racket/contract/private/blame.rkt b/racket/collects/racket/contract/private/blame.rkt index cc9d71c071..4f4c07151e 100644 --- a/racket/collects/racket/contract/private/blame.rkt +++ b/racket/collects/racket/contract/private/blame.rkt @@ -278,7 +278,7 @@ [(blame-value blme) (format "~a: ~a" (blame-value blme) self-or-not)] [else - (format "~a:" self-or-not)])) + (format "~a" self-or-not)])) (define blame-parties (blame-positive blme)) (define blaming-line @@ -308,9 +308,17 @@ (from-info (blame-negative blme)))]) (format " contract from: ~a" from-negative-message)))) + (define custom-message-appears-to-start-with-fields? + (regexp-match? #rx"[^\n]*:" custom-message)) + (combine-lines - start-of-message - (format " ~a" custom-message) + (if custom-message-appears-to-start-with-fields? + start-of-message + (string-append start-of-message ";")) + (format (if custom-message-appears-to-start-with-fields? + " ~a" + " ~a") + custom-message) context-lines (if context-lines contract-line