Skip to content

ThreadCallbacks discarding exceptions #12983

Description

@ncannasse

I saw this code in ThreadCallbacks:

	static function iterateCallbacks<F>(callbacks:Array<ThreadCallback<F>>, f:ThreadCallback<F> -> Void) {
		var firstException = null;
		for (c in callbacks) {
			if (!c.isClosed) {
				try {
					f(c);
				} catch(e:Exception) {
					if (firstException == null) {
						firstException = e;
					}
				}
			}
		}
		if (firstException != null) {
			throw firstException;
		}
	}

I think it's a very bad idea for several reasons

  • it prevents the debugger from breaking at the place you have an exception, you're instead breaking on the throw firstException
  • it somehow discard all user exceptions happening after the first one, which is really a bad behavior from the user point of view.

In general, the whole "exception during abort or exit which triggers onAbort" is not very well thought through.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions