app: port app to use the system package

This commit does away with almost all baggage left over from the Ego port. Error wrapping also got simplified. All API changes happens to be internal which means no changes to main except renaming of the BaseError type.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
2024-10-16 01:38:59 +09:00
parent 430f1a5b4e
commit 084cd84f36
15 changed files with 144 additions and 671 deletions

View File

@@ -6,11 +6,12 @@ import (
"os"
"git.ophivana.moe/cat/fortify/internal/app"
"git.ophivana.moe/cat/fortify/internal/fmsg"
)
func logWaitError(err error) {
var e *app.BaseError
if !app.AsBaseError(err, &e) {
var e *fmsg.BaseError
if !fmsg.AsBaseError(err, &e) {
fmt.Println("fortify: wait failed:", err)
} else {
// Wait only returns either *app.ProcessError or *app.StateStoreError wrapped in a *app.BaseError
@@ -31,7 +32,7 @@ func logWaitError(err error) {
// every error here is wrapped in *app.BaseError
for _, ei := range errs {
var eb *app.BaseError
var eb *fmsg.BaseError
if !errors.As(ei, &eb) {
// unreachable
fmt.Println("fortify: invalid error type returned by revert:", ei)
@@ -46,9 +47,9 @@ func logWaitError(err error) {
}
func logBaseError(err error, message string) {
var e *app.BaseError
var e *fmsg.BaseError
if app.AsBaseError(err, &e) {
if fmsg.AsBaseError(err, &e) {
fmt.Print("fortify: " + e.Message())
} else {
fmt.Println(message, err)