Howto catch SocketOSException?
Jolly James via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Mar 26 14:57:29 PDT 2017
On Sunday, 26 March 2017 at 18:50:13 UTC, bauss wrote:
> On Sunday, 26 March 2017 at 11:46:39 UTC, Jolly James wrote:
>>>[...]
>
> Chances are it's invoked in another thread and thus you can't
> catch it like that.
>
> To sum it up.
>
> Ex.
>
> void thisFunctionThrows() { ... }
>
> void ableToCatch() {
> try {
> thisFunctionThrows();
> }
> catch (Exception e) {
> // We can catch the exception ...
> }
> }
>
> void notAbleToCatch() {
> try {
> spawn(&thisFunctionThrows);
> }
> catch (Exception e) {
> // We cannot catch the exception ...
> }
> }
>
> void ableToCatchToo() {
> spawn(&ableToCatch); // We're able to handle the exception,
> because the try/catch is handled in the thread that calls the
> function that throws.
> }
If you want try to help me, mabye this helps you:
https://github.com/CyberShadow/ae/blob/master/net/asockets.d#L1237
More information about the Digitalmars-d-learn
mailing list