I try to make may own version of raise-argument-error:
(define (raise-argument-error* a b c)
(raise
(exn:fail:contract
(format "~a: contract violation\n expected: ~a\n given: ~a" a b c)
(current-continuation-marks)))
(void))
(define (test1 x)
(when (> x 0)
(raise-argument-error 'test1 "<= 0" x))
(+ x 1))
(define (test2 x)
(when (> x 0)
(raise-argument-error* 'test2 "<= 0" x))
(+ x 1))
Then, a call (test1 2)
shows in stracktrace:
test-raise.rkt:12:4
(raise-argument-error 'test1 "<= 0" x))
test-raise.rkt:11:2
(when (> x 0)
(raise-argument-error 'test1 "<= 0" x))
interactions from an unsaved editor:6:2
> (test1 2)
But (test2 2)
gives :
test-raise.rkt:7:6
(current-continuation-marks)))
test-raise.rkt:5:4
(exn:fail:contract
(format "~a: contract violation\n expected: ~a\n given: ~a" a b c)
(current-continuation-marks)))
test-raise.rkt:4:2
(raise
(exn:fail:contract
(format "~a: contract violation\n expected: ~a\n given: ~a" a b c)
(current-continuation-marks)))
test-raise.rkt:17:4
(raise-argument-error* 'test2 "<= 0" x))
interactions from an unsaved editor:10:2
> (test2 2)
Is it possible to add frame
(when (> x 0)
(raise-argument-error* 'test2 "<= 0" x))
like it is with raise-argument-error version?