Why writeln can't be converted to nothrow with just catching of StdioException

Mike Parker aldacron at gmail.com
Mon Feb 21 11:21:52 UTC 2022

On Monday, 21 February 2022 at 11:07:55 UTC, Basile B. wrote:
> Yeah there must be another one then. Something actionnable is 
> the documentation.

This has nothing to do with which exceptions types a function 
throws. The compiler doesn't dig into that. You have to catch 

import std.stdio;

class MyException : Exception {
     this(string msg) { super(msg); }

void throwing(int x) {
     if(x > 2) throw new MyException("Derp!");
     else writeln(x);

void noThrowing() nothrow {
     try {
     catch(MyException me) {}

void main()

onlineapp.d(14): Error: function `onlineapp.throwing` is not 
onlineapp.d(12): Error: `nothrow` function `onlineapp.noThrowing` 
may throw

More information about the Digitalmars-d-learn mailing list