Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Refactor maybe to return backup value when exp evaluated to undefined

dominik-zeglen34a16eca7914
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.ts
index 0005713f54..8dda640185 100644
--- a/saleor/static/dashboard-next/misc.ts
+++ b/saleor/static/dashboard-next/misc.ts
@@ -147,7 +147,8 @@ export const translatedTaxRates = () => ({
export function maybe<T>(exp: () => T, d?: T) {
try {
- return exp();
+ const result = exp();
+ return result === undefined ? d : result;
} catch {
return d;
}