fix: \loadActivePositionData\ has no error handling — silent failure on RPC error (#377)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-03 01:51:48 +00:00
parent f0377c5b81
commit 8e600ec5fd

View file

@ -35,6 +35,10 @@
</div> </div>
</template> </template>
<div class="collapsed-body"> <div class="collapsed-body">
<div v-if="error" class="collapsed-body--error">
<span>{{ error }}</span>
<FButton size="tiny" outlined @click="loadActivePositionData">Retry</FButton>
</div>
<div class="profit-stats-wrapper"> <div class="profit-stats-wrapper">
<div class="profit-stats-item"> <div class="profit-stats-item">
<div><b>Tax Paid</b></div> <div><b>Tax Paid</b></div>
@ -117,6 +121,7 @@ const taxDue = ref<bigint>(0n);
const taxPaidGes = ref<number>(); const taxPaidGes = ref<number>();
const profit = ref<number>(); const profit = ref<number>();
const loading = ref<boolean>(false); const loading = ref<boolean>(false);
const error = ref<string | null>(null);
const tag = computed(() => { const tag = computed(() => {
// Compare by index instead of decimal to avoid floating-point issues // Compare by index instead of decimal to avoid floating-point issues
@ -214,14 +219,23 @@ async function unstakePosition() {
} }
async function loadActivePositionData() { async function loadActivePositionData() {
//loadTaxDue loading.value = true;
taxDue.value = await getTaxDue(props.id); error.value = null;
taxPaidGes.value = weiToNumber(taxDue.value + props.position.taxPaid); try {
//loadTaxDue
taxDue.value = await getTaxDue(props.id);
taxPaidGes.value = weiToNumber(taxDue.value + props.position.taxPaid);
//loadTotalSupply //loadTotalSupply
// Calculate issuance earned using kraiken-lib profit calculation // Calculate issuance earned using kraiken-lib profit calculation
profit.value = calculateActivePositionProfit(props.position.totalSupplyInit, statCollection.kraikenTotalSupply, props.position.share); profit.value = calculateActivePositionProfit(props.position.totalSupplyInit, statCollection.kraikenTotalSupply, props.position.share);
} catch (err) {
console.error('Failed to load active position data:', err);
error.value = 'Failed to load position data.';
} finally {
loading.value = false;
}
} }
onMounted(() => { onMounted(() => {
@ -317,6 +331,13 @@ onMounted(() => {
&.profit-stats-total &.profit-stats-total
border-top: 2px solid var(--color-font) border-top: 2px solid var(--color-font)
padding-top: 2px padding-top: 2px
.collapsed-body--error
display: flex
align-items: center
gap: 8px
color: #f87171
font-size: 13px
margin-bottom: 8px
.collapsed-body--actions .collapsed-body--actions
.collapse-menu-open .collapse-menu-open
display: flex display: flex