| 1 | // examples/varargs_preamble.h
 | 
| 2 | 
 | 
| 3 | #include <exception>
 | 
| 4 | 
 | 
| 5 | #include "mycpp/runtime.h"
 | 
| 6 | 
 | 
| 7 | //
 | 
| 8 | // Copied from cpp/core_error.h
 | 
| 9 | //
 | 
| 10 | 
 | 
| 11 | namespace error {
 | 
| 12 | 
 | 
| 13 | class _ErrorWithLocation : public std::exception {
 | 
| 14 |  public:
 | 
| 15 |   _ErrorWithLocation(BigStr* user_str, int span_id) {
 | 
| 16 |   }
 | 
| 17 | };
 | 
| 18 | 
 | 
| 19 | class Parse : public _ErrorWithLocation {
 | 
| 20 |  public:
 | 
| 21 |   Parse(BigStr* user_str, int span_id) : _ErrorWithLocation(user_str, span_id) {
 | 
| 22 |   }
 | 
| 23 | };
 | 
| 24 | 
 | 
| 25 | class FatalRuntime : public _ErrorWithLocation {
 | 
| 26 |  public:
 | 
| 27 |   FatalRuntime(BigStr* user_str) : _ErrorWithLocation(user_str, -1) {
 | 
| 28 |   }
 | 
| 29 | };
 | 
| 30 | 
 | 
| 31 | };
 | 
| 32 | 
 | 
| 33 | //
 | 
| 34 | // Copied from cpp/core_pyerror.h
 | 
| 35 | //
 | 
| 36 | 
 | 
| 37 | [[noreturn]] inline void p_die(BigStr* s, int span_id) {
 | 
| 38 |   throw new error::Parse(s, span_id);
 | 
| 39 | }
 | 
| 40 | 
 | 
| 41 | [[noreturn]] inline void e_die(BigStr* s) {
 | 
| 42 |   throw new error::FatalRuntime(s);
 | 
| 43 | }
 | 
| 44 | 
 | 
| 45 | [[noreturn]] inline void e_die(BigStr* s, int span_id) {
 | 
| 46 |   throw new error::FatalRuntime(s);
 | 
| 47 | }
 |