Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6231885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:00:55+00:00 2026-05-24T10:00:55+00:00

I’m trying to learn how to write Erlang Webmachine resources. One resource throws an

  • 0

I’m trying to learn how to write Erlang Webmachine resources. One resource throws an error, but I can’t tracking it down. The error message in the crash report does not provide enough information.

Is there a way to test these functions in the Erlang shell?

Most of the functions in the resource require request and context parameters. But I don’t know how to simulate these parameters in the browser.

Example code below.

Thanks,

LRP

Example code:

I’m thinking specifically of functions like:

content_types_provided(RD, Ctx) ->
   Path = wrq:disp_path(RD),
   {[{webmachine_util:guess_mime(Path), generate_body}],
   RD, Ctx}.

But my current bug is in the init function.

This works…

Dispatch rule:

{["blip"], zzz_resource, []}.

Init:

init([]) -> {ok, undefined}.

to_html(ReqData, State) ->
    % {"<html><bodoy>Hello, new world</body></html>", ReqData, State}.
        {test:test(), ReqData, State}.

But this throws an error:

Dispatch:

{["static"], static_resource,[]}.

Init:

init(_) ->
   DocRoot =
       case init:get_argument(doc_root) of
          {ok, [[DR]]} -> DR;
           error -> "doc_root path error"
       end,
   {ok, #ctx{docroot=DocRoot}}.

=ERROR REPORT==== 4-Aug-2011::10:54:56 ===
webmachine error: path="/static"
{error,function_clause,
   [{filename,join,[[]]},
    {static_resource,resource_exists,2},
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:00:56+00:00Added an answer on May 24, 2026 at 10:00 am

    There are a lot of layers to this answer depending on what you want to see and how deep down the rabbit hole you want to go.


    Let’s start with the easy stuff:

    The error you are getting tells me that a call to static_resource:resource_exists/2 resulted in a call to filename:join/1 which failed because it was passed [] as its argument. That should help you track down the issue.

    Recommended reading: errors-and-exceptions


    A crude way to track down errors in any language is just to add print statements at strategic loctations. In this case you can use io:format/2 or erlang:display/1 to display whatever you want to the console. For example:

    ...
    erlang:display("I'm inside resource_exists!"),
    StuffToJoin = ["foo", "bar"],
    erlang:display(StuffToJoin),
    filename:join(StuffToJoin),
    ...
    

    Just reload the page you should see the value printed in the console (assuming the appropriate function was called as part of the reload).


    If you want to manually test a resource (like in a unit test) you can do something like the following:

    Headers = [{"Host", "mydomain.com"}, {"user-agent", "Firefox"}],
    Context = [],
    Path = "/static",
    ReqData = wrq:create('GET', {1,1}, Path, mochiweb_headers:from_list(Headers)),
    static_resource:resource_exists(ReqData, Context)
    

    If you want a deep look at how to debug webmachine, you can read this. You can get pretty far with the above, but doing a full trace can be helpful if you need to see the decision graph.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.