source: src/Common/ErrorObjects.hpp @ 0cb3479

Last change on this file since 0cb3479 was 16ba4897, checked in by Andrew Beach <ajbeach@…>, 6 weeks ago

Replaced SemanticErrorException::isEmpty with ...::throwIfNonEmpty. This is how it was used in every context and it saves a bit of text (if not two lines) at every use. I considered putting this function in the header for better inlining, but this should have at least the same preformance as the last version.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// ErrorObjects.hpp --
8//
9// Author           : Thierry Delisle
10// Created On       : Wed Feb 28 15:16:47 2018
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16#pragma once
17
18
19#include <exception>    // for exception
20#include <iostream>     // for ostream
21#include <list>         // for list
22#include <string>               // for string
23#include <unistd.h>     // for isatty
24
25#include "CodeLocation.hpp"                                                             // for CodeLocation, toString
26
27struct error {
28        CodeLocation location;
29        std::string description;
30
31        error() = default;
32        error( CodeLocation loc, const std::string & str ) : location( loc ), description( str ) {}
33};
34
35class SemanticErrorException : public std::exception {
36  public:
37        SemanticErrorException() = default;
38        SemanticErrorException( CodeLocation location, std::string error );
39        ~SemanticErrorException() throw() {}
40
41        void append( SemanticErrorException & other );
42        void append( CodeLocation location, const std::string & );
43        void throwIfNonEmpty();
44        void print();
45  private:
46        std::list< error > errors;
47};
Note: See TracBrowser for help on using the repository browser.