add makeSystemError*() helper functions
authorAdam Simpkins <simpkins@fb.com>
Sat, 2 Dec 2017 02:05:54 +0000 (18:05 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 2 Dec 2017 02:22:05 +0000 (18:22 -0800)
commit20272b4ec1c1ac41cc6bd408b8c454794873d4fb
tree5b4574a61968496729e2e3957eb640e7f32c1dc4
parentad993b99e320a3e16d1671efe38052f0df203eb4
add makeSystemError*() helper functions

Summary:
Add makeSystemError() helper functions that are similar to the existing
throwSystemError() functions but just return the exception rather than throwing
it.  This is helpful for callers using folly::Expected or folly::Future, where
they need to return an exception type rather than throwing it.

This also includes comments about the fact that this code is using the wrong
error category.  The C++ standard indicates that std::generic_category() for
POSIX errno values.  I am not fixing this as part of this diff, since this
change has the potential to break existing users, and would need a fair amount
of testing first.

Reviewed By: yfeldblum

Differential Revision: D6456771

fbshipit-source-id: 4724b51b8d4a7f513ae70ea1b0c4f0516cfc205f
folly/Exception.h
folly/test/ExceptionTest.cpp