sapling/eden/fs/store/hg/HgImportPyError.h
Zeyi (Rice) Fan 6ae87b04f6 eden: remove hg_import_helper.py
Reviewed By: simpkins

Differential Revision: D18602771

fbshipit-source-id: bf004911251b7380d1c4c21c07241c7d0a853c61
2019-12-03 09:30:09 -08:00

67 lines
1.4 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/Range.h>
#include <stdexcept>
#include <string>
namespace facebook {
namespace eden {
/**
* All exceptions received from `hg debugedenimporthelper` are thrown in C++ as
* HgImportPyError exceptions.
*/
class HgImportPyError : public std::exception {
public:
HgImportPyError(folly::StringPiece errorType, folly::StringPiece message);
const char* what() const noexcept override {
return fullMessage_.c_str();
}
/**
* The name of the python exception type.
*/
folly::StringPiece errorType() const noexcept {
return errorType_;
}
/**
* The python exception message.
*/
folly::StringPiece message() const noexcept {
return message_;
}
private:
static constexpr folly::StringPiece kSeparator{": "};
/**
* The full message to return from what().
* This always has the form "errorType: message"
*/
const std::string fullMessage_;
/**
* The name of the python exception type.
* This points to a substring of fullMessage_.
*/
const folly::StringPiece errorType_;
/**
* The python exception message.
* This points to a substring of fullMessage_.
*/
const folly::StringPiece message_;
};
} // namespace eden
} // namespace facebook