mesos-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Mahler (JIRA)" <j...@apache.org>
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
                 URL: https://issues.apache.org/jira/browse/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:

{code}
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();
}
{code}

This leads to the following error messages:

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

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|https://issues.apache.org/jira/browse/MESOS-785?focusedCommentId=15590263&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15590263]
in MESOS-785 for additional context.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message