mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-02 08:53:38 -04:00
A bit of error logging for #1220.
This commit is contained in:
parent
3862bd2376
commit
abcc75a6f2
1 changed files with 9 additions and 6 deletions
|
@ -64,7 +64,7 @@ class CocoModel extends Backbone.Model
|
||||||
|
|
||||||
@backedUp = {}
|
@backedUp = {}
|
||||||
schema: -> return @constructor.schema
|
schema: -> return @constructor.schema
|
||||||
|
|
||||||
getValidationErrors: ->
|
getValidationErrors: ->
|
||||||
errors = tv4.validateMultiple(@attributes, @constructor.schema or {}).errors
|
errors = tv4.validateMultiple(@attributes, @constructor.schema or {}).errors
|
||||||
return errors if errors?.length
|
return errors if errors?.length
|
||||||
|
@ -76,7 +76,7 @@ class CocoModel extends Backbone.Model
|
||||||
for error in errors
|
for error in errors
|
||||||
console.debug "\t", error.dataPath, ":", error.message
|
console.debug "\t", error.dataPath, ":", error.message
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
save: (attrs, options) ->
|
save: (attrs, options) ->
|
||||||
options ?= {}
|
options ?= {}
|
||||||
options.headers ?= {}
|
options.headers ?= {}
|
||||||
|
@ -97,19 +97,19 @@ class CocoModel extends Backbone.Model
|
||||||
noty text: "#{errorMessage}: #{res.status} #{res.statusText}", layout: 'topCenter', type: 'error', killer: false, timeout: 10000
|
noty text: "#{errorMessage}: #{res.status} #{res.statusText}", layout: 'topCenter', type: 'error', killer: false, timeout: 10000
|
||||||
@trigger "save", @
|
@trigger "save", @
|
||||||
return super attrs, options
|
return super attrs, options
|
||||||
|
|
||||||
patch: (options) ->
|
patch: (options) ->
|
||||||
return false unless @_revertAttributes
|
return false unless @_revertAttributes
|
||||||
options ?= {}
|
options ?= {}
|
||||||
options.patch = true
|
options.patch = true
|
||||||
|
|
||||||
attrs = {_id: @id}
|
attrs = {_id: @id}
|
||||||
keys = []
|
keys = []
|
||||||
for key in _.keys @attributes
|
for key in _.keys @attributes
|
||||||
unless _.isEqual @attributes[key], @_revertAttributes[key]
|
unless _.isEqual @attributes[key], @_revertAttributes[key]
|
||||||
attrs[key] = @attributes[key]
|
attrs[key] = @attributes[key]
|
||||||
keys.push key
|
keys.push key
|
||||||
|
|
||||||
return unless keys.length
|
return unless keys.length
|
||||||
console.debug 'Patching', @get('name') or @, keys
|
console.debug 'Patching', @get('name') or @, keys
|
||||||
@save(attrs, options)
|
@save(attrs, options)
|
||||||
|
@ -207,7 +207,10 @@ class CocoModel extends Backbone.Model
|
||||||
|
|
||||||
applyDelta: (delta) ->
|
applyDelta: (delta) ->
|
||||||
newAttributes = $.extend(true, {}, @attributes)
|
newAttributes = $.extend(true, {}, @attributes)
|
||||||
jsondiffpatch.patch newAttributes, delta
|
try
|
||||||
|
jsondiffpatch.patch newAttributes, delta
|
||||||
|
catch error
|
||||||
|
console.error "Error applying delta", delta, "to attributes", newAttributes, error
|
||||||
@set newAttributes
|
@set newAttributes
|
||||||
|
|
||||||
getExpandedDelta: ->
|
getExpandedDelta: ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue