// // exception.h // dice-roll // // Created by Sam Jaffe on 12/1/18. // Copyright © 2018 Sam Jaffe. All rights reserved. // #pragma once #include namespace dice { class unexpected_token : public std::runtime_error { public: /** * @brief An error for failure to parse a string into a dice::dice object * @param reason The specific reason that this error occured * @param position The index into the string that the error was located at, * or -1(EOF) if the error was a 'we ran out of buffer' type. */ unexpected_token(std::string const & reason, long long position); /** * @brief Create a string matching the regex '~*^', that points to the error * covered by this exception class. * @param backup_length If {@see unexpected_token::position} == -1, use * this value instead as N. * @return A string of N '~' and one '^', pointing to the character in the * parse string that the error occured at. * "" if position and backup_length are both -1 */ std::string pointer(long long backup_length = -1) const; private: long long position; }; }