aboutsummaryrefslogtreecommitdiff
path: root/src/tools/math-evaluator/math-evaluator.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/math-evaluator/math-evaluator.vue')
-rw-r--r--src/tools/math-evaluator/math-evaluator.vue9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/tools/math-evaluator/math-evaluator.vue b/src/tools/math-evaluator/math-evaluator.vue
index 26fb6b1..59754de 100644
--- a/src/tools/math-evaluator/math-evaluator.vue
+++ b/src/tools/math-evaluator/math-evaluator.vue
@@ -21,18 +21,13 @@
</template>
<script setup lang="ts">
+import { withDefaultOnError } from '@/utils/defaults';
import { evaluate } from 'mathjs';
import { computed, ref } from 'vue';
const expression = ref('');
-const result = computed(() => {
- try {
- return evaluate(expression.value) ?? '';
- } catch (_) {
- return '';
- }
-});
+const result = computed(() => withDefaultOnError(() => evaluate(expression.value) ?? '', ''));
</script>
<style lang="less" scoped></style>