saracalihan/ASstdlib

ErrorOr<T> implementation

Opened this issue · 0 comments

currently, we throw exceptions on unexpected errors or something went wrong. But, it crashes the whole workflow. So we need to wrapper for the functions.

ErrorOr<T> {
  value: T = NULL,
  error: Exception = NULL,
  has_error: boolean = false,
  error_message: string = NULL,
}
int getUserCount(bool countAdmin);

ErrorOr<int> value = ErrorOr<int>([](){
  return getUserCount(false);
});