1317017Sdim//===- BinaryStreamError.h - Error extensions for Binary Streams *- C++ -*-===// 2317017Sdim// 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 6317017Sdim// 7317017Sdim//===----------------------------------------------------------------------===// 8317017Sdim 9317017Sdim#ifndef LLVM_SUPPORT_BINARYSTREAMERROR_H 10317017Sdim#define LLVM_SUPPORT_BINARYSTREAMERROR_H 11317017Sdim 12317017Sdim#include "llvm/ADT/StringRef.h" 13317017Sdim#include "llvm/Support/Error.h" 14317017Sdim 15317017Sdim#include <string> 16317017Sdim 17317017Sdimnamespace llvm { 18317017Sdimenum class stream_error_code { 19317017Sdim unspecified, 20317017Sdim stream_too_short, 21317017Sdim invalid_array_size, 22317017Sdim invalid_offset, 23317017Sdim filesystem_error 24317017Sdim}; 25317017Sdim 26317017Sdim/// Base class for errors originating when parsing raw PDB files 27317017Sdimclass BinaryStreamError : public ErrorInfo<BinaryStreamError> { 28317017Sdimpublic: 29317017Sdim static char ID; 30317017Sdim explicit BinaryStreamError(stream_error_code C); 31317017Sdim explicit BinaryStreamError(StringRef Context); 32317017Sdim BinaryStreamError(stream_error_code C, StringRef Context); 33317017Sdim 34317017Sdim void log(raw_ostream &OS) const override; 35317017Sdim std::error_code convertToErrorCode() const override; 36317017Sdim 37317017Sdim StringRef getErrorMessage() const; 38317017Sdim 39317017Sdim stream_error_code getErrorCode() const { return Code; } 40317017Sdim 41317017Sdimprivate: 42317017Sdim std::string ErrMsg; 43317017Sdim stream_error_code Code; 44317017Sdim}; 45317017Sdim} // namespace llvm 46317017Sdim 47317017Sdim#endif // LLVM_SUPPORT_BINARYSTREAMERROR_H 48