[Error] Add FileError helper; upgrade StringError behavior
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>
Thu, 30 Aug 2018 13:10:42 +0000 (13:10 +0000)
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>
Thu, 30 Aug 2018 13:10:42 +0000 (13:10 +0000)
commite11f221786c9c70a0ccdfdfff454dc552abd9a21
tree78bc9d2eb19c1f26bae0ae9f54ec2644a7bad39f
parent2fab235316e6e35300e632fe1cf1312aeaa7d68c
[Error] Add FileError helper; upgrade StringError behavior

FileError is meant to encapsulate both an Error and a file name/path. It should be used in cases where an Error occurs deep down the call chain, and we want to return it to the caller along with the file name.

StringError was updated to display the error messages in different ways. These can be:

1. display the error_code message, and convert to the same error_code (ECError behavior)
2. display an arbitrary string, and convert to a provided error_code (current StringError behavior)
3. display both an error_code message and a string, in this order; and convert to the same error_code

These behaviors can be triggered depending on the constructor. The goal is to use StringError as a base class, when a library needs to provide a explicit Error type.

Differential Revision: https://reviews.llvm.org/D50807

llvm-svn: 341064
llvm/include/llvm/Support/Error.h
llvm/lib/Support/Error.cpp
llvm/unittests/Support/ErrorTest.cpp