LLVM  10.0.0svn
BinaryStreamError.cpp
Go to the documentation of this file.
1 //===- BinaryStreamError.cpp - Error extensions for streams -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
11 
12 using namespace llvm;
13 
14 char BinaryStreamError::ID = 0;
15 
17  : BinaryStreamError(C, "") {}
18 
21 
23  : Code(C) {
24  ErrMsg = "Stream Error: ";
25  switch (C) {
27  ErrMsg += "An unspecified error has occurred.";
28  break;
30  ErrMsg += "The stream is too short to perform the requested operation.";
31  break;
33  ErrMsg += "The buffer size is not a multiple of the array element size.";
34  break;
36  ErrMsg += "The specified offset is invalid for the current stream.";
37  break;
39  ErrMsg += "An I/O error occurred on the file system.";
40  break;
41  }
42 
43  if (!Context.empty()) {
44  ErrMsg += " ";
45  ErrMsg += Context;
46  }
47 }
48 
49 void BinaryStreamError::log(raw_ostream &OS) const { OS << ErrMsg; }
50 
52 
53 std::error_code BinaryStreamError::convertToErrorCode() const {
54  return inconvertibleErrorCode();
55 }
uint64_t CallInst * C
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void log(raw_ostream &OS) const override
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:140
Base class for errors originating when parsing raw PDB files.
BinaryStreamError(stream_error_code C)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
StringRef getErrorMessage() const
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77