redstone-dart / redstone_mapper_mongo

MongoDB extension for redstone_mapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change response status from a mapper

GeReinhart opened this issue · comments

This code do not return a 404. The response is lost : the client never get the response back... I'm using redstone 0.5.20

@app.Group("/services")
@Encode()
class UserService extends MongoDbService<User> {
  UserService() : super("users");

@app.Route("/login/:openId", methods: const [app.POST])
  Future<User> login(@Decode() User user) {
    return findOne({"openId": user.openId}).then((user) {
      if (user == null) {
        throw new app.ErrorResponse(404, {"error": "no user with openId ${user.openId}"});
      }
  ...

Is there another way to do it ?

Just upgraded to redstone 0.5.21 and it's working fine.