Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.9.26

- `Initializable` mixin:
- `ensureInitialized`: added `onError` handler to `then` call to route errors to `_onInitializationError`.
- `executeInitializedCallback`:
- Added `onError` handler to `then` call on async initialization result to throw `InitializationError` with stack trace.
- `_FutureExtension`:
- `toCompleter`: added `onError` handler to `then` to complete completer with error and stack trace if not completed.

## 1.9.25

- `TableFieldReference`:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bones_api_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef APILogger =
/// Bones API Library class.
class BonesAPI {
// ignore: constant_identifier_names
static const String VERSION = '1.9.25';
static const String VERSION = '1.9.26';

static bool _boot = false;

Expand Down
39 changes: 27 additions & 12 deletions lib/src/bones_api_initializable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ mixin Initializable {
}

return _finalizeInitializationWithDeps2(depsResults, result);
});
}, onError: (e, s) => _onInitializationError(e, s));
} else {
return _finalizeInitializationWithDeps2(depsResults, result);
}
Expand Down Expand Up @@ -1107,13 +1107,21 @@ mixin Initializable {
var ret = ensureInitialized(parent: parent);

if (ret is Future<InitializationResult>) {
return ret.then((result) {
if (!result.ok) {
_forceLogFlushMessages();
return ret.then(
(result) {
if (!result.ok) {
_forceLogFlushMessages();
throw InitializationError(
this,
"Error initializing (async): $this",
);
}
return callback();
},
onError: (e, s) {
throw InitializationError(this, "Error initializing (async): $this");
}
return callback();
});
},
);
} else {
if (!ret.ok) {
_forceLogFlushMessages();
Expand Down Expand Up @@ -1284,11 +1292,18 @@ extension _FutureExtension<T> on Future<T> {
Completer<T> toCompleter() {
var completer = Completer<T>();
// ignore: discarded_futures
then((val) {
if (!completer.isCompleted) {
completer.complete(val);
}
});
then(
(val) {
if (!completer.isCompleted) {
completer.complete(val);
}
},
onError: (e, s) {
if (!completer.isCompleted) {
completer.completeError(e, s);
}
},
);
return completer;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bones_api
description: Bones_API - A powerful API backend framework for Dart. It comes with a built-in HTTP Server, route handler, entity handler, SQL translator, and DB adapters.
version: 1.9.25
version: 1.9.26
homepage: https://github.com/Colossus-Services/bones_api

environment:
Expand Down