blob: 55c17aeb2152c806ef8165d5024f26aa80817421 [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Parses a value to an integer
/// Handles cases when the value is already an integer
int parseInt(Object value, {int onError(String source)}) {
if (value is int) {
return value;
} else {
return int.tryParse(value) ?? onError(value);
}
}