ufront / ufront-mvc

The core MVC framework that powers ufront
MIT License
17 stars 15 forks source link

UFAsyncApi.hx:88: lines 88-168 : Missing return tink.Surprise<_makeApiCall.A, ufront.remoting.RemotingError<_makeApiCall.B>> #11

Closed ianharrigan closed 9 years ago

ianharrigan commented 9 years ago

Hi Jason,

Im writing a really basic ufront server to use a test server for something else, however, im getting this:

UFAsyncApi.hx:88: lines 88-168 : Missing return tink.Surprise<_makeApiCall.A, ufront.remoting.RemotingError<_makeApiCall.B>>

This was previously working. Ive updated all libs to no avail. The source is really skeleton:

class Main {
    public static function main() {
        run();
    }

    private static function run():Void {
        var app:UfrontApplication = new UfrontApplication({
            indexController: IndexController,
        });
        app.executeRequest();
    }
}
class IndexController extends Controller {
    @post public function init() {
        context.session.init();
    }

    @:route("/actions/*") var actions:ActionsController;
}
class ActionsController extends Controller {
    @:route("/hello/$name")
    public function hello(name:String = "stranger") {
        var result = {
            message: "Hello, " + name,
            name: name
        };
        return new JsonResult(result);
    }
}

Any ideas? As i mentioned, this was working previously, so not sure what has changed.

Cheers, Ian

ianharrigan commented 9 years ago

btw, for now ive just made the function _makeApiCall<A,B> return null as i dont need it, and everything works fine.

jasononeil commented 9 years ago

Hi Ian, sorry for not getting to this earlier.

TL,DR: Try adding -D server to your compilation.

It looks like the error is coming from the use of conditional compilation, where I use #if server .... #elseif client .... #end. If you compile with -D server it would insert the logic for the server, if you compile with -D client it would insert the logic for the client side. If you don't have either, the function does not have a return, and the compiler errors out, even though you are not using the class.

Once the new minject is released I'll be doing an updated release of ufront (which will define "-D server" when it is used) and ufront-client (which will define "-D client" when it is used). Both of them depend on ufront-mvc, which can run on the server or the client.

Sorry for the confusion here. Let me know how it goes for you - and feel free to re-open if that doesn't fix the issue.