mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-05-02 15:53:10 +00:00
17 lines
347 B
TypeScript
17 lines
347 B
TypeScript
import { SafeValue } from "@codex-storage/sdk-js";
|
|
import { Errors } from "./errors";
|
|
|
|
export const Promises = {
|
|
rejectOnError: <T>(safe: SafeValue<T>, report = true) => {
|
|
if (safe.error) {
|
|
if (report) {
|
|
Errors.report(safe)
|
|
}
|
|
|
|
return Promise.reject(safe.data);
|
|
}
|
|
|
|
return Promise.resolve(safe.data);
|
|
},
|
|
};
|