@@ -9,7 +9,7 @@ import { IModelApp, QuantityType } from "@itwin/core-frontend";
9
9
import { FormatTraits } from "@itwin/core-quantity" ;
10
10
import { MeasureTools } from "../MeasureTools.js" ;
11
11
12
- import type { FormatProps , FormatterSpec } from "@itwin/core-quantity" ;
12
+ import type { FormatDefinition , FormatProps , FormatterSpec } from "@itwin/core-quantity" ;
13
13
export namespace FormatterUtils {
14
14
15
15
/**
@@ -226,17 +226,13 @@ export namespace FormatterUtils {
226
226
* @returns A FormatterSpec for bearing formatting.
227
227
*/
228
228
export async function getBearingFormatterSpec ( bearingKoQ : string , persistenceUnitName : string ) : Promise < FormatterSpec | undefined > {
229
- let formatProps : FormatProps | undefined ;
230
-
229
+ let formatProps : FormatDefinition ;
231
230
try {
232
- // First try to get format props from the formats provider using the bearingKoQ
233
- formatProps = await IModelApp . formatsProvider . getFormat ( bearingKoQ ) ;
231
+ // Get format props from the formats provider using the bearingKoQ. If undefined, use default bearing format
232
+ const result = await IModelApp . formatsProvider . getFormat ( bearingKoQ ) ;
233
+ formatProps = result ?? getDefaultBearingFormatProps ( ) ;
234
234
} catch {
235
- // If that fails, formatProps will remain undefined and we'll use the fallback
236
- }
237
-
238
- // If we couldn't get format props from the provider, use the default bearing format
239
- if ( ! formatProps ) {
235
+ // If an error occurs, use the default bearing format
240
236
formatProps = getDefaultBearingFormatProps ( ) ;
241
237
}
242
238
0 commit comments