Перенос страниц
This commit is contained in:
parent
4d57446057
commit
4c954c9186
129 changed files with 14 additions and 15 deletions
29
book/03-инструкции/src/chapter-3-11/app.d
Normal file
29
book/03-инструкции/src/chapter-3-11/app.d
Normal file
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* 1. Объявите класс, который наследуется от Exception.
|
||||
* 2. Создайте конструктор, который принимает, как минимум, два параметра: string file и
|
||||
* size_t line, со значениями по умолчанию __FILE__ и __LINE__ соответственно.
|
||||
* 3. Попросите конструктора переслать аргументы конструктору исключения (super).
|
||||
* 4. Используйте свое исключение.
|
||||
*/
|
||||
|
||||
class MyException : Exception
|
||||
{
|
||||
this (string message, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
|
||||
{
|
||||
super(message, file, line, next);
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
import std.stdio;
|
||||
|
||||
try
|
||||
{
|
||||
throw new MyException("message here");
|
||||
}
|
||||
catch(MyException e)
|
||||
{
|
||||
writeln("caught ", e);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue