index/functions/errorMessageCaseNormalization.md
errorMessageCaseNormalization(
message):string
Normalize error message to lowercase for consistent error pattern matching.
Converts error messages to lowercase for case-insensitive substring searching. Useful for matching specific error conditions regardless of message casing.
Consolidated from 8 duplicated patterns in error type matching:
error.message.toLowerCase().includes('pattern')message.toLowerCase().includes('insufficient')
to lower case
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | The error message to normalize |
Returns
string
Lowercase version of the message
Examples
Error pattern matching
import { errorMessageCaseNormalization } from '@gala-chain/launchpad-sdk';
try {
// ... operation
} catch (error: unknown) {
const normalized = errorMessageCaseNormalization(error.message);
if (normalized.includes('insufficient balance')) {
// Handle insufficient balance
}
}
Transaction error categorization
import { errorMessageCaseNormalization } from '@gala-chain/launchpad-sdk';
const errorMsg = 'TRANSACTION FAILED: Insufficient Balance';
const normalized = errorMessageCaseNormalization(errorMsg);
if (normalized.includes('insufficient')) {
console.log('Balance error');
}
if (normalized.includes('transaction')) {
console.log('Tx error');
}
Since
6.14.0