factor/basis/tools/errors/errors.factor

45 lines
1.3 KiB
Factor
Raw Normal View History

! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs debugger io kernel sequences source-files.errors
summary accessors continuations make math.parser io.styles namespaces
2009-04-23 23:17:25 -04:00
compiler.errors prettyprint ;
IN: tools.errors
#! Tools for source-files.errors. Used by tools.tests and others
#! for error reporting
2009-04-23 23:17:25 -04:00
M: source-file-error compute-restarts error>> compute-restarts ;
2009-04-23 23:17:25 -04:00
M: source-file-error error-help error>> error-help ;
CONSTANT: +listener-input+ "<Listener input>"
2009-04-17 16:50:11 -04:00
M: source-file-error summary
[
[ file>> [ % ": " % ] [ +listener-input+ % ] if* ]
2009-04-17 16:50:11 -04:00
[ line#>> [ # ] when* ] bi
2009-04-23 23:17:25 -04:00
] "" make ;
2009-04-17 16:50:11 -04:00
M: source-file-error error.
2009-04-23 23:17:25 -04:00
[ summary print nl ]
[ "Asset: " write asset>> short. nl ]
[ error>> error. ]
tri ;
: errors. ( errors -- )
group-by-source-file sort-errors
[
[ nl "==== " write +listener-input+ or print nl ]
[ [ nl ] [ error. ] interleave ]
bi*
] assoc-each ;
2009-04-23 23:17:25 -04:00
: :errors ( -- ) compiler-errors get values errors. ;
2009-04-23 23:17:25 -04:00
: :linkage ( -- ) linkage-errors get values errors. ;
M: not-compiled summary
word>> name>> "The word " " cannot be executed because it failed to compile" surround ;
M: not-compiled error.
[ summary print nl ] [ error>> error. ] bi ;