Skip to content

Using import (require) function "Cant find file/folder" exception flow not nicely handled #11

@calebrepkes

Description

@calebrepkes

Hey,

While building and expanding my code, I made two mistakes both leading to the same type of exception handling:

Engine: 462458762 - Exception handling routing table request com.sandbox.common.models.ServiceScriptException: Cannot find module: ./mockedServices/MYFILE.js in <sandbox-internal> at line number 243 at column number 6 at com.sandbox.runtime.js.services.Service.loadService(Service.java:202) ~[sandbox:na] at com.sandbox.runtime.js.services.Service.initialize(Service.java:102) ~[sandbox:na] at com.sandbox.runtime.js.services.Service.handleRoutingTableRequest(Service.java:148) ~[sandbox:na] at com.sandbox.runtime.HttpRequestHandler.handle(HttpRequestHandler.java:100) [sandbox:na] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [sandbox:na] at org.eclipse.jetty.server.Server.handle(Server.java:499) [sandbox:na] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [sandbox:na] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [sandbox:na] at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [sandbox:na] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [sandbox:na] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [sandbox:na] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74] Error processing request com.sandbox.common.models.ServiceScriptException: Cannot find module: ./mockedServices/MYFILE.js in <sandbox-internal> at line number 243 at column number 6 at com.sandbox.runtime.js.services.Service.loadService(Service.java:202) ~[sandbox:na] at com.sandbox.runtime.js.services.Service.initialize(Service.java:102) ~[sandbox:na] at com.sandbox.runtime.js.services.Service.handleRoutingTableRequest(Service.java:148) ~[sandbox:na] at com.sandbox.runtime.HttpRequestHandler.handle(HttpRequestHandler.java:100) ~[sandbox:na] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [sandbox:na] at org.eclipse.jetty.server.Server.handle(Server.java:499) [sandbox:na] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [sandbox:na] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [sandbox:na] at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [sandbox:na] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [sandbox:na] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [sandbox:na] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74]

  1. My first mistake was not adding / in the following var:
    var routeMYROUTE = require('./mockedServices/MYFILE')

  2. My second mistake was saving the file in the root folder, instead of in the folder ./mockedServices.

Would be nicer if the exception handling could point a bit better to the spot where its going wrong. This was my main.js file line 22. While the exception handler says its at line number 243, while I don't even have that line in both my main.js or MYFILE.js

Just my two cents, trying to give you feedback.

Note: Mistakes didnt happen with the same operation. But I noticed the same handling. And took me quite a while to find what was going wrong. Especially with the second thing. As code wise everything looked good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions