Title: Theory / Unimportant / CS / Programming / C++ / Abseil / Status
Tags: automatedNewLineAfterCommaSpace
On every note of this deck, unless a note says otherwise:
Language: c++

Typ: absl::Status
Meaning: absl mechanism to gracefully handle errors across API boundaries (and in particular across RPC boundaries).
Page: https://abseil.io/docs/cpp/guides/status
Language: C++

Typ: absl::StatusCode
Meaning: A status code in ABSL
Page: https://abseil.io/docs/cpp/guides/status
Language: c++
Context: absl

Typ: absl::StatusCode::kOk
Meaning: the singleton type of the ok status
Page: https://abseil.io/docs/cpp/guides/status
Language: c++
Context: absl

Instruction: absl::StatusCode()
Page: https://abseil.io/docs/cpp/guides/status
Returns: an ok status
Typ: absl::StatusCode::kOk

Question: What should be done with function returning absl::Status
Answer: Function calling it should use the status. Either check it or return it
Page: https://abseil.io/docs/cpp/guides/status
Context: c++

Question: What should be done in case of a method returning an error status
Answer: Low-level method should pass it
Page: https://abseil.io/docs/cpp/guides/status
Context: c++
Answer2: You should log it, except if you're too low level to be relevant (e.g. open)
Answer3: method that can deal with it should take care of restarting the try or warning the user it failed if possible

Instruction: status.ok()
Page: https://abseil.io/docs/cpp/guides/status
Returns: whether the status is ok
Variables: Status status

Instruction: absl::IsInvalidArgument(status)
Page: https://abseil.io/docs/cpp/guides/status
Returns: whether the status is not ok
Variables: Status status

Typ: absl::statusOr<Type>
Meaning: Either a value of Type or an error status
Page: https://abseil.io/docs/cpp/guides/status
Language: c++
Variables: Type

Instruction: status_or.ok()
Page: https://abseil.io/docs/cpp/guides/status
Returns: whether status_or has a value
Variables: absl::statusOr<Type> status_or

Instruction: status_or.status()
Page: https://abseil.io/docs/cpp/guides/status
Returns: the status of status_or
Variables: absl::statusOr<Type> status_or

Instruction: *status_or
Page: https://abseil.io/docs/cpp/guides/status
Returns: the value in this status_or. Undefined if not ok
Variables: absl::statusOr<Type> status_or

Instruction: status.IgnoreError()
Page: https://abseil.io/docs/cpp/guides/status
Effect: ensure no warning occurs, even if the status is not used
Variables: absl::status status

Instruction: first_status.Update(second_status)
Page: https://abseil.io/docs/cpp/guides/status
Returns: first_status if it is an error, otherwise second_status
Variables: absl::status first_status second_status

Instruction: status.message()
Page: https://abseil.io/docs/cpp/guides/status
Returns: the message associated to this status
Variables: absl::status status()

Instruction: status.ToString()
Page: https://abseil.io/docs/cpp/guides/status
Returns: A string representing this status. Exact value depends on the "mode"
Variables: absl::status status()

Instruction: status.GetPayLoad(foo)
Page: https://abseil.io/docs/cpp/guides/status
Returns: the payload associated to the url foo, if any.
Variables: absl::status status()
Typ: absl::optional<absl::Cord>

Instruction: status.SetPayLoad(
  foo,
  data
)
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
Returns: Add a payload data associated to the url foo to the status. Does nothing for okay value
Variables: absl::status status(
)

Instruction: status.ErasePayLoad(url)
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
Effect: Remove the payload associated to url
Returns: whether the payload was present
Variables: absl::status status()
Assuming: status is not ok

Instruction: status.ForEachPayload(f)
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
Effect: apply f to each pair url/payload of the status
Variables: absl::status status()
Assuming: status is not ok

Instruction: absl::Status(code)
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
Effect: A status with code
Exception: throw or crash depending on settings if the status is ok

Instruction: absl::OkStatus()
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
Effect: The ok status

Instruction: absl::Status(
  code,
  message
)
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h
Returns: A failing status with code and message

Instruction: absl::StatusOr()
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/statusor.h
Returns: A status or with kUnknown code

Instruction: absl::StatusOr<Type>(args)
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/statusor.h
Returns: The okay status Type({args})

Instruction: status_or.value()
Page: https://github.com/abseil/abseil-cpp/blob/master/absl/status/statusor.h
Returns: the value saved in this status
Variables: absl::StatusOr<Type> status_or
Exception: absl::BadStatusOrAccess if not ok