1353358Sdim//===- GenericError.h - system_error extensions for PDB ---------*- C++ -*-===//
2303231Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6303231Sdim//
7303231Sdim//===----------------------------------------------------------------------===//
8303231Sdim
9303231Sdim#ifndef LLVM_DEBUGINFO_PDB_ERROR_H
10303231Sdim#define LLVM_DEBUGINFO_PDB_ERROR_H
11303231Sdim
12314564Sdim#include "llvm/ADT/StringRef.h"
13303231Sdim#include "llvm/Support/Error.h"
14303231Sdim
15303231Sdimnamespace llvm {
16303231Sdimnamespace pdb {
17303231Sdim
18344779Sdimenum class pdb_error_code {
19344779Sdim  invalid_utf8_path = 1,
20303231Sdim  dia_sdk_not_present,
21344779Sdim  dia_failed_loading,
22344779Sdim  signature_out_of_date,
23360784Sdim  no_matching_pch,
24303231Sdim  unspecified,
25303231Sdim};
26344779Sdim} // namespace pdb
27344779Sdim} // namespace llvm
28303231Sdim
29344779Sdimnamespace std {
30344779Sdimtemplate <>
31344779Sdimstruct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {};
32344779Sdim} // namespace std
33344779Sdim
34344779Sdimnamespace llvm {
35344779Sdimnamespace pdb {
36344779Sdimconst std::error_category &PDBErrCategory();
37344779Sdim
38344779Sdiminline std::error_code make_error_code(pdb_error_code E) {
39344779Sdim  return std::error_code(static_cast<int>(E), PDBErrCategory());
40344779Sdim}
41344779Sdim
42303231Sdim/// Base class for errors originating when parsing raw PDB files
43344779Sdimclass PDBError : public ErrorInfo<PDBError, StringError> {
44303231Sdimpublic:
45344779Sdim  using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors
46344779Sdim  PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {}
47303231Sdim  static char ID;
48303231Sdim};
49344779Sdim} // namespace pdb
50344779Sdim} // namespace llvm
51303231Sdim#endif
52