#1 2025-10-10 16:04:39

testgary
Member
Registered: 2025-02-06
Posts: 37

EMvcApplication.GotoError

procedure TBlogApplication.AuthorView(var ID: TID; var Author: TOrmAuthor; out Articles: variant);
begin
  RestModel.Orm.Retrieve(ID, Author);
  Author.HashedPassword := ''; 
  if Author.ID <> 0 then
    Articles := RestModel.Orm.RetrieveDocVariantArray(TOrmArticle, '',
      'Author=? order by RowId desc limit 50', [ID], ARTICLE_FIELDS)
  else
    EMvcApplication.GotoError(HTTP_NOTFOUND);
end; 

When opening this link http://localhost:8092/blog/AuthorView, the backend directly exits and an exception message pops up.

Offline

#2 2025-10-10 16:39:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,240
Website

Re: EMvcApplication.GotoError

Where? In the IDE?
This is a regular exception. So by default, it will popup in the IDE. You need to disable the EMvcApplication exception class in your IDE options.

But a cleaner (and faster) way, now available with latest TMvcApplication, is to call RedirectError() instead.
Update your framework source code and your sample source.

Offline

#3 2025-10-10 16:59:40

testgary
Member
Registered: 2025-02-06
Posts: 37

Re: EMvcApplication.GotoError

mormot '2.3.11868'

When running in the Lazarus IDE, and when running directly, it crashes. I don’t want the site to stop; if I execute this directly, the backend crashes, because your example was written that way, so I tested it.

I now have a requirement: if the user is not logged in, do not render the HTML code—return a notice page or return an informational message directly. Otherwise, I want to wrap the entire frontend source with {{#CookieData.Status}} ALL HTML {{/CookieData.Status}}.

I’m not sure whether my idea and direction are correct, or if there are other methods! I’m using an interface-based approach, and it seems I can’t use the gotoerror method, so I’m lost.

Offline

#4 2025-10-10 17:12:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,240
Website

Re: EMvcApplication.GotoError

Update your framework source code and your sample source.

Offline

Board footer

Powered by FluxBB