PolyToolkit.PolyStatus

Using PolyStatus vs.

Summary

throwing exceptions: PolyStatus typically represents an "expected" failure, that is, an operation where failure is common and acceptable. For example, validating user input, consuming some external file which might or might not be well formatted, sending a web request, etc. For unexpected failures (logic errors, assumption violations, etc), it's best to use exceptions.

Constructors and Destructors

PolyStatus(bool ok, string errorMessage)
Creates a new PolyStatus with the given success status and error message.

Public attributes

errorMessage
string
If the operation failed, this is the error message.
ok
bool
Indicates whether the operation succeeded.

Public functions

ToString()
override string

Public static functions

Error(string errorMessage)
Creates a new error status with the given error message.
Error(string format, params object[] args)
Creates a new error status with the given error message.
Error(PolyStatus cause, string errorMessage)
Creates a new error status with the given error message and cause.
Error(PolyStatus cause, string format, params object[] args)
Creates a new error status with the given error message and cause.
Success()
Creates a new success status.

Public attributes

errorMessage

string PolyToolkit::PolyStatus::errorMessage

If the operation failed, this is the error message.

This is an error message suitable for logging, not necessarily a user-friendly message.

ok

bool PolyToolkit::PolyStatus::ok

Indicates whether the operation succeeded.

Public functions

PolyStatus

 PolyToolkit::PolyStatus::PolyStatus(
  bool ok,
  string errorMessage
)

Creates a new PolyStatus with the given success status and error message.

Details
Parameters
ok
Whether the operation succeeded.
errorMessage
The error message (only relevant if ok == false).

ToString

override string PolyToolkit::PolyStatus::ToString()

Public static functions

Error

PolyStatus PolyToolkit::PolyStatus::Error(
  string errorMessage
)

Creates a new error status with the given error message.

Error

PolyStatus PolyToolkit::PolyStatus::Error(
  string format,
  params object[] args
)

Creates a new error status with the given error message.

Error

PolyStatus PolyToolkit::PolyStatus::Error(
  PolyStatus cause,
  string errorMessage
)

Creates a new error status with the given error message and cause.

The error message will automatically include all error messages in the causal chain.

Error

PolyStatus PolyToolkit::PolyStatus::Error(
  PolyStatus cause,
  string format,
  params object[] args
)

Creates a new error status with the given error message and cause.

The error message will automatically include all error messages in the causal chain.

Success

PolyStatus PolyToolkit::PolyStatus::Success()

Creates a new success status.