error_builders.h 853 B

1234567891011121314151617181920212223242526
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_EXPLORER_COMMON_ERROR_BUILDERS_H_
  5. #define CARBON_EXPLORER_COMMON_ERROR_BUILDERS_H_
  6. #include "common/error.h"
  7. #include "explorer/common/source_location.h"
  8. namespace Carbon {
  9. // Builds an Error instance with the specified message. This should be used
  10. // for errors in the user-supplied Carbon code is incorrect. Use CHECK/FATAL
  11. // instead for errors that indicate bugs in Explorer itself.
  12. //
  13. // For example:
  14. // return ProgramError(line_num) << "Line is bad!";
  15. inline auto ProgramError(SourceLocation loc) -> ErrorBuilder {
  16. return ErrorBuilder(loc.ToString());
  17. }
  18. } // namespace Carbon
  19. #endif // CARBON_EXPLORER_COMMON_ERROR_BUILDERS_H_