dev/vala/hello/exception.vala

47 lines
881 B
Vala
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

public errordomain ErrType01
{
ERROR_CODE_01
}
public errordomain ErrType02
{
ERROR_TYPE_02
}
public class MyClass : GLib.Object
{
public static void myfunc_throw() throws ErrType01, ErrType02
{
throw new ErrType01.ERROR_CODE_01( "Ошибка с кодом 01" );
}
public static void myfunc_catch() throws ErrType02
{
try
{
myfunc_throw();
}
catch( ErrType01 e )
{
// Здесь обрабатываются ошибки из домена ErrType01
}
finally
{
// Освобождение ресурсов и прочие необходимые операции
}
}
public static int main( string[] args )
{
try
{
myfunc_catch();
}
catch( ErrType02 e )
{
// Здесь обрабатываются ошибки из домена ErrType02
}
return 0;
}
}