Spicy
result.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <hilti/ast/operators/common.h>
6 #include <hilti/ast/types/result.h>
7 
8 namespace hilti {
9 namespace operator_ {
10 
11 STANDARD_OPERATOR_1(result, Deref, operator_::dereferencedType(0), type::constant(type::Result(type::Wildcard())),
12  "Retrieves value stored inside the result instance. Will throw a ``NoResult`` exception if the "
13  "result is in an error state.");
14 
15 BEGIN_METHOD(result, Error)
16  auto signature() const {
17  return Signature{.self = type::Result(type::Wildcard()),
18  .result = type::Error(),
19  .id = "error",
20  .args = {},
21  .doc =
22  "Retrieves the error stored inside the result instance. Will throw a ``NoError`` "
23  "exception if the result is not in an error state."};
24  }
25 END_METHOD
26 
27 } // namespace operator_
28 } // namespace hilti