mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-05-01 01:04:43 +00:00
Estimated hours taken: 8 Move exception handling into the standard library, and change error/1 so that it throws an exception. This has two advantages: one is that user code can now catch exceptions caused by calls to error/1, the other is that the debugger handles calls to error/1 more gracefully (by virtue of its existing support for exception handling). extras/exceptions/exception.m: library/exception.m: Move exception.m from `extras' into the standard library. Change the code for handling uncaught exceptions so that it prints out the same diagnostics that error/1 used to print out (i.e. a stack trace and the last debugger event number). extras/exceptions/Mmakefile: extras/exceptions/test_exceptions.exp: extras/exceptions/test_exceptions.m: extras/exceptions/test_exceptions_func.exp: extras/exceptions/test_exceptions_func.m: extras/exceptions/test_uncaught_exception.exp: extras/exceptions/test_uncaught_exception.m tests/hard_coded/exceptions/Mmakefile: tests/hard_coded/exceptions/test_exceptions.exp: tests/hard_coded/exceptions/test_exceptions.m: tests/hard_coded/exceptions/test_exceptions_func.exp: tests/hard_coded/exceptions/test_exceptions_func.m: tests/hard_coded/exceptions/test_uncaught_exception.exp: tests/hard_coded/exceptions/test_uncaught_exception.exp2: tests/hard_coded/exceptions/test_uncaught_exception.m Move the exception test cases from extras/exceptions to a new directory tests/hard_coded/exceptions. Also, change the expected output for the `test_uncaught_exception' test case, since it now prints out more information. tests/hard_coded/Mmakefile: Add `exceptions' to the list of subdirectories. extras/exceptions/README: Delete this file, since the files that it refers to have now all been moved elsewhere. library/require.m: Change error/1 so that it throws an exception. library/library.m: Add exceptions.m to the list of modules in the standard library.
27 lines
793 B
Mathematica
27 lines
793 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1997-1998 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU Library General
|
|
% Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
%---------------------------------------------------------------------------%
|
|
|
|
% File: test_uncaught_exception.m.
|
|
% Main author: fjh.
|
|
|
|
% A test case for exception handling.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module test_uncaught_exception.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
:- import_module std_util.
|
|
:- import_module exception.
|
|
|
|
main -->
|
|
{ throw("<exception thrown from main>") }.
|
|
|