Globalize current-context error messages

This commit is contained in:
Miroslav Bajtoš 2016-08-10 13:37:25 +02:00
parent b087c930ed
commit 59a82a9d5e
3 changed files with 22 additions and 20 deletions

View File

@ -3,6 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
var g = require('strong-globalize')();
var juggler = require('loopback-datasource-juggler');
var remoting = require('strong-remoting');
@ -10,23 +11,23 @@ module.exports = function(loopback) {
juggler.getCurrentContext =
remoting.getCurrentContext =
loopback.getCurrentContext = function() {
throw new Error(
'loopback.getCurrentContext() was removed in version 3.0. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'loopback.getCurrentContext()',
'https://docs.strongloop.com/display/APIC/Using%20current%20context'));
};
loopback.runInContext = function(fn) {
throw new Error(
'loopback.runInContext() was removed in version 3.0. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'loopback.runInContext()',
'https://docs.strongloop.com/display/APIC/Using%20current%20context'));
};
loopback.createContext = function(scopeName) {
throw new Error(
'loopback.createContext() was removed in version 3.0. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'loopback.createContext()',
'https://docs.strongloop.com/display/APIC/Using%20current%20context'));
};
};

View File

@ -4,7 +4,8 @@
// License text available at https://opensource.org/licenses/MIT
module.exports = function() {
throw new Error('loopback#context middleware was removed in version 3.0. ' +
'See https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
throw new Error(g.f(
'%s middleware was removed in version 3.0. See %s for more details.',
'loopback#context',
'https://docs.strongloop.com/display/APIC/Using%20current%20context'));
};

View File

@ -9,7 +9,7 @@
var loopback = require('../../lib/loopback');
var async = require('async');
var deprecate = require('depd')('loopback');
var g = require('strong-globalize')();
/*!
* Export the middleware.
@ -41,10 +41,10 @@ function rest() {
var contextOptions = remotingOptions.context;
if (contextOptions !== undefined && contextOptions !== false) {
throw new Error(
'remoting.context option was removed in version 3.0. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'remoting.context option',
'https://docs.strongloop.com/display/APIC/Using%20current%20context'));
}
if (app.isAuthEnabled) {