:: [DNG] Error handling alternatives (…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: karl
Fecha:  
A: dng
Temas antiguos: Re: [DNG] another programming language question
Asunto: [DNG] Error handling alternatives (was Re: another programming language question)
Didier:
...
>     As usual, in Ada, you have several options to achieve your goal and
> it is up to you to choose the most elegant. You can also use the
> try-block method suggested by Karl, by inserting a short nested subprogram:
>
> begin
> /some code which might raise the exception/
> exception
> /the exception-handling code/
> end


In cpp, you have __FILE__, __func__ and __LINE__ (though when compiled
for c89 you don't get __func__) so I can get outputs like:

2024-10-16_21:33:53: ERR run.c 62: <cnti != cnto> cnti = 0, cnto = 3
2024-10-16_21:33:53: INFO write2grbl.c 101: <run(save.fd, &sigmask) < 0>
2024-10-16_21:33:53: NOTICE write2grbl.c 104: write2grbl: /dev/ttyUSB0 closed and restored
or:
2024-10-25_15:51:56: NOTICE write2grbl.c main() 137: write2grbl: /dev/ttyUSB0 closed and restored

I.e. I can see what file, function (depending on c version) and line
number, also I can follow the failure path. Can you do something
similar in ADA ?

Regards,
/Karl Hammar