[Yunq] Return status from client calls.
This commit is contained in:
parent
700f3f94cb
commit
c209925a3c
25 changed files with 102 additions and 112 deletions
|
|
@ -11,11 +11,11 @@ class Status {
|
|||
Status(ErrorCode code) : code_(code), message_() {}
|
||||
Status(ErrorCode code, StringView message) : code_(code), message_(message) {}
|
||||
|
||||
explicit operator bool() { return ok(); }
|
||||
bool ok() { return code_ == OK; }
|
||||
explicit operator bool() const { return ok(); }
|
||||
bool ok() const { return code_ == OK; }
|
||||
|
||||
ErrorCode code() { return code_; }
|
||||
StringView message() { return message_; }
|
||||
ErrorCode code() const { return code_; }
|
||||
StringView message() const { return message_; }
|
||||
|
||||
private:
|
||||
ErrorCode code_;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,11 @@ glcr::ErrorOr<glcr::Vector<glcr::String>> ListDirectory(glcr::StringView path) {
|
|||
GetDirectoryRequest req;
|
||||
req.set_path(path);
|
||||
Directory dir;
|
||||
RET_ERR(gVfsClient->GetDirectory(req, dir));
|
||||
auto status = gVfsClient->GetDirectory(req, dir);
|
||||
if (!status.ok()) {
|
||||
dbgln("Error in getting directory: {}", status.message());
|
||||
return status.code();
|
||||
}
|
||||
|
||||
auto file_views = glcr::StrSplit(dir.filenames(), ',');
|
||||
glcr::Vector<glcr::String> files;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@ void check(uint64_t code) {
|
|||
(void)ZProcessExit(code);
|
||||
}
|
||||
|
||||
void check(const glcr::Status& status) {
|
||||
if (status.ok()) {
|
||||
return;
|
||||
}
|
||||
dbgln("Crash: {}", status.message());
|
||||
(void)ZProcessExit(status.code());
|
||||
}
|
||||
|
||||
void crash(const char* str, uint64_t code) {
|
||||
dbgln(str);
|
||||
(void)ZProcessExit(code);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/status.h>
|
||||
#include <glacier/string/str_format.h>
|
||||
#include <glacier/string/string_view.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -16,5 +17,6 @@ void dbgln(const glcr::StringView& fmt, Args... args) {
|
|||
// Checks that the code is ok.
|
||||
// if not exits the process.
|
||||
void check(uint64_t);
|
||||
void check(const glcr::Status&);
|
||||
|
||||
void crash(const char*, z_err_t);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue