MCPcopy Index your code
hub / github.com/hapijs/hapi / execute

Method execute

lib/toolkit.js:42–110  ·  view source on GitHub ↗
(method, request, options)

Source from the content-addressed store, hash-verified

40 }
41
42 async execute(method, request, options) {
43
44 const h = new this._toolkit(request, options);
45 const bind = options.bind ?? null;
46
47 try {
48 let operation;
49
50 if (bind) {
51 operation = method.call(bind, request, h);
52 }
53 else if (options.args) {
54 operation = method(request, h, ...options.args);
55 }
56 else {
57 operation = method(request, h);
58 }
59
60 var response = await exports.timed(operation, options);
61 }
62 catch (err) {
63 if (Bounce.isSystem(err)) {
64 response = Boom.badImplementation(err);
65 }
66 else if (!Bounce.isError(err)) {
67 response = Boom.badImplementation('Cannot throw non-error object', err);
68 }
69 else {
70 response = Boom.boomify(err);
71 }
72 }
73
74 // Process response
75
76 if (options.ignoreResponse) {
77 return response;
78 }
79
80 if (response === undefined) {
81 response = Boom.badImplementation(`${method.name} method did not return a value, a promise, or throw an error`);
82 }
83
84 if (options.continue &&
85 response === exports.symbols.continue) {
86
87 if (options.continue === 'undefined') {
88 return;
89 }
90
91 // 'null'
92
93 response = null;
94 }
95
96 if (options.auth &&
97 response instanceof internals.Auth) {
98
99 return response;

Callers 7

handler.jsFile · 0.80
_invokeMethod · 0.80
failActionMethod · 0.80
testMethod · 0.80
_authenticateMethod · 0.80
payloadMethod · 0.80
responseMethod · 0.80

Calls 3

wrapMethod · 0.80
_prepareMethod · 0.80
methodFunction · 0.50

Tested by 1

testMethod · 0.64