Loading...
Searching...
No Matches
juce::Result Class Reference

## Detailed Description

Represents the 'success' or 'failure' of an operation, and holds an associated error message to describe the error when there's a failure.

E.g.

Result myOperation()
{
if (doSomeKindOfFoobar())
return Result::ok();
else
return Result::fail ("foobar didn't work!");
}
const Result result (myOperation());
if (result.wasOk())
{
...it's all good...
}
else
{
warnUserAboutFailure ("The foobar operation failed! Error message was: "
+ result.getErrorMessage());
}
juce::Result
Represents the 'success' or 'failure' of an operation, and holds an associated error message to descr...
Definition juce_Result.h:69
juce::Result::fail
static Result fail(const String &errorMessage) noexcept
Creates a 'failure' result.
juce::Result::Result
Result(const Result &)
juce::Result::ok
static Result ok() noexcept
Creates and returns a 'successful' result.
Definition juce_Result.h:73

The documentation for this class was generated from the following file:

- juce_core/misc/juce_Result.h

## Public Member Functions

bool | wasOk () const noexcept
| Returns true if this result indicates a success.
bool | failed () const noexcept
| Returns true if this result indicates a failure.
| operator bool () const noexcept
| Returns true if this result indicates a success.
bool | operator! () const noexcept
| Returns true if this result indicates a failure.
const String & | getErrorMessage () const noexcept
| Returns the error message that was set when this result was created.
| Result (const Result &)
Result & | operator= (const Result &)
| Result (Result &&) noexcept
Result & | operator= (Result &&) noexcept
bool | operator== (const Result &other) const noexcept
bool | operator!= (const Result &other) const noexcept

## Static Public Member Functions

static Result | ok () noexcept
| Creates and returns a 'successful' result.
static Result | fail (const String &errorMessage) noexcept
| Creates a 'failure' result.

## Constructors and Destructors

## Result() [1/2]

juce::Result::Result | ( | const Result & |  | ) |

References Result().

Referenced by fail(), ok(), operator!=(), operator=(), operator=(), operator==(), Result(), and Result().

## Result() [2/2]

juce::Result::Result | ( | Result && |  | ) |

noexcept

References Result().

## Member Functions

## ok()

Result juce::Result::ok | ( |  | ) |

inline static noexcept

Creates and returns a 'successful' result.

References Result().

## fail()

Result juce::Result::fail | ( | const String & | errorMessage | ) |

static noexcept

Creates a 'failure' result.

If you pass a blank error message in here, a default "Unknown Error" message will be used instead.

References Result().

## wasOk()

bool juce::Result::wasOk | ( |  | ) | const

noexcept

Returns true if this result indicates a success.

## failed()

bool juce::Result::failed | ( |  | ) | const

noexcept

Returns true if this result indicates a failure.

You can use getErrorMessage() to retrieve the error message associated with the failure.

References failed().

Referenced by failed().

## operator bool()

juce::Result::operator bool | ( |  | ) | const

noexcept

Returns true if this result indicates a success.

This is equivalent to calling wasOk().

## operator!()

bool juce::Result::operator! | ( |  | ) | const

noexcept

Returns true if this result indicates a failure.

This is equivalent to calling failed().

## getErrorMessage()

const String & juce::Result::getErrorMessage | ( |  | ) | const

noexcept

Returns the error message that was set when this result was created.

For a successful result, this will be an empty string;

References getErrorMessage().

Referenced by getErrorMessage().

## operator=() [1/2]

Result & juce::Result::operator= | ( | const Result & |  | ) |

References Result().

## operator=() [2/2]

Result & juce::Result::operator= | ( | Result && |  | ) |

noexcept

References Result().

## operator==()

bool juce::Result::operator== | ( | const Result & | other | ) | const

noexcept

References Result().

## operator!=()

bool juce::Result::operator!= | ( | const Result & | other | ) | const

noexcept

References Result().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited