destructor error handling got more thorough analysis...
This commit is contained in:
parent
9212dfc814
commit
218f6eacb1
20
BASED.md
20
BASED.md
@ -928,11 +928,11 @@ A legjobb egy Zig-szerű megoldás lenne - jelenleg ezt mondanám a választáso
|
|||||||
void testcode() {
|
void testcode() {
|
||||||
// onfail clause is mandatory if function declaration has an onfail - unlike with exceptions
|
// onfail clause is mandatory if function declaration has an onfail - unlike with exceptions
|
||||||
// Its "errors as values" philosophy and implemented via record returns / double return values.
|
// Its "errors as values" philosophy and implemented via record returns / double return values.
|
||||||
FileHandle h = open_file("help.txt") onfail(err) {
|
FileHandle h = open_file("help.txt") onfail(DatabaseError err) {
|
||||||
// Must handle all of the cases (or have a "default"?)
|
// Must handle all of the cases (or have a "default"?)
|
||||||
NOT_FOUND:
|
NOT_FOUND:
|
||||||
// Can chain, and have visibility for variables in the main expression (here: h)
|
// Can chain, and have visibility for variables in the main expression (here: h)
|
||||||
h = open_file("secondary_help.txt") onfail(err2) {
|
h = open_file("secondary_help.txt") onfail(DatabaseConnection err2) {
|
||||||
default:
|
default:
|
||||||
printf("help.txt not found and secondary_help.txt errs with: %s\n", err2.msg());
|
printf("help.txt not found and secondary_help.txt errs with: %s\n", err2.msg());
|
||||||
}
|
}
|
||||||
@ -970,7 +970,19 @@ FONTOS (destruktor error):
|
|||||||
DatabaseConnection dc;
|
DatabaseConnection dc;
|
||||||
dc.insert(...);
|
dc.insert(...);
|
||||||
dc.commit();
|
dc.commit();
|
||||||
} onfail(err) {
|
DatabaseConnection dc2;
|
||||||
|
dc2.insert(...);
|
||||||
|
dc2.commit();
|
||||||
|
SocketConnection sc;
|
||||||
|
sc.insert(...);
|
||||||
|
sc.commit();
|
||||||
|
} onfail(DatabaseError dc.err) { // TODO: Jó-e a syntax? Itt a dc adja meg minek a dekonstruktora futott (elhagyható)
|
||||||
|
CannotClose:
|
||||||
|
...
|
||||||
|
} onfail(DatabaseError dc2.err) {
|
||||||
|
CannotClose:
|
||||||
|
...
|
||||||
|
} onfail(SocketError err) {
|
||||||
CannotClose:
|
CannotClose:
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
@ -978,6 +990,8 @@ FONTOS (destruktor error):
|
|||||||
Megjegyzés: A scope végére helyezett onfail talán kiválthatná a lokálisat / függvényhívás pontján lévőt?
|
Megjegyzés: A scope végére helyezett onfail talán kiválthatná a lokálisat / függvényhívás pontján lévőt?
|
||||||
Ekkor talán javasolt lenne a scope-osnál a teljes típust kiírni, mert többféle tagged enum lehet?
|
Ekkor talán javasolt lenne a scope-osnál a teljes típust kiírni, mert többféle tagged enum lehet?
|
||||||
|
|
||||||
|
Megjegyzés: thread_local-ba tehet mondjuk error esetén void* plusz adatot az error kiváltó kód (ha kell). (szabvány v egyedi?)
|
||||||
|
|
||||||
FONTOS:
|
FONTOS:
|
||||||
|
|
||||||
A fentieknek működnie kell konstruktor esetén is (destruktornál viszont semmiképp). Gondolj bele: az kell a RAII-hoz!
|
A fentieknek működnie kell konstruktor esetén is (destruktornál viszont semmiképp). Gondolj bele: az kell a RAII-hoz!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user