mesos-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Mahler (JIRA)" <>
Subject [jira] [Created] (MESOS-6423) Establish error message guidelines in the style guide.
Date Thu, 20 Oct 2016 00:15:58 GMT
Benjamin Mahler created MESOS-6423:

             Summary: Establish error message guidelines in the style guide.
                 Key: MESOS-6423
             Project: Mesos
          Issue Type: Improvement
          Components: documentation, technical debt
            Reporter: Benjamin Mahler

We currently have a "pattern" for writing error messages that enables composition. The rule
for synchronous error composition is as follows:

Try<FileDescriptor> open(string path)
  return Error("File not found"));

Try<string> read(int fd)
  return Error("Invalid file descriptor");

  Try<FileDescriptor> open = ::open("path");
  if (open.isError()) {
    return Error("Failed to open 'path': " + open.error());

  FileDescriptor fd = open.get();

  Try<string> read = ::read(fd);

  if (read.isError()) {
    return Error("Failed to read from file at 'path' (fd " + stringify(fd) + "): " + read.error());

  return read.get();

This leads to the following error messages:

Failed to open 'path': File not found
Failed to read from opened file at 'path' (fd 4): Invalid file descriptor

The pattern in use for error messages is:

* Callees do not include caller-available context (i.e. the arguments provided) as this can
easily lead to double logging. I.e. callers only include the reason that they are surfacing
an error.
* Callers add their context to the reason provided by the callee.

This ticket is to document the pattern in use for synchronous code paths.

Note that this pattern can't be used with the design of {{Future::then}}. We need to determine
how to provide error composition for Futures as well. See [my comment|]
in MESOS-785 for additional context.

This message was sent by Atlassian JIRA

View raw message