Skip to content

Commit

Permalink
Globalize current-context error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Aug 10, 2016
1 parent b087c93 commit 59a82a9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
25 changes: 13 additions & 12 deletions lib/current-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
// 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');

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'));
};
};
7 changes: 4 additions & 3 deletions server/middleware/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
};
10 changes: 5 additions & 5 deletions server/middleware/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 59a82a9

Please sign in to comment.