How do I make a span set itself as in an error state without bubbling an exception all the way up to the top of the job and erroring out of the whole task?
For example, this task could be an error state but I can't figure out how to say that it is:
@dagger.function
async dev lint() -> RuffLintResults:
result = await (
_ruff_container(self.source, await _get_version(self.source))
.with_exec(
[
"ruff",
"check",
"--output-format=gitlab",
"--output-file=/tmp/lint-report.json",
],
expect=dagger.ReturnType.ANY,
)
.sync()
)
report_file = result.file("/tmp/lint-report.json")
to_return RuffLintResults(
exit_code=await result.exit_code(),
stdout=await result.stdout(),
stderr=await result.stderr(),
report_file=report_file,
report_contents=gitlab.CodeQualityIssue.list_from_json(await report_file.contents()),
)
if exit_code != 0:
dag.set_this_span_as_red_and_broken("Here is a really well formatted error message describing where and how you should fix your commit.")
return to_return
This is probably related to https://github.com/dagger/dagger/issues/8421